Created
March 15, 2013 13:50
-
-
Save lucasnad27/5170005 to your computer and use it in GitHub Desktop.
Genealogy Line Work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
import urllib | |
base_url = 'http://lucasnad27.cartodb.com/api/v2/sql' | |
api_key = 'none of your business' | |
delete_sql = urllib.quote('delete from CONNECTORS') | |
insert_sql = urllib.quote('Insert into connectors (the_geom,person_id) select ST_MakeLine(points), c.person_id from (select n.the_geom as points, n.person_id from nodes as n order by start_date) c group by c.person_id') | |
req = urllib2.Request('%s/?q=%s&api_key=%s' % (base_url, delete_sql, api_key)) | |
response = urllib2.urlopen(req) | |
print response.read() | |
req = urllib2.Request('%s/?q=%s&api_key=%s' % (base_url, insert_sql, api_key)) | |
response = urllib2.urlopen(req) | |
print response.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Insert into connectors (the_geom,person_id) | |
select | |
ST_MakeLine(points), | |
c.person_id from | |
( | |
select | |
n.the_geom as points, | |
n.person_id | |
from nodes as n | |
order by start_date | |
) c | |
group by c.person_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment