from collections import deque from cartodb import CartoDB, CartoDBException import secret user = secret.user password = secret.password CONSUMER_KEY = secret.CONSUMER_KEY CONSUMER_SECRET = secret.CONSUMER_SECRET cartodb_domain = user OSM_CHANGES_RSS = 'http://www.openstreetmap.org/browse/changesets/feed' # connect to cartodb cl = CartoDB(CONSUMER_KEY, CONSUMER_SECRET, user, password, cartodb_domain) etag = None modified = None ids = deque(maxlen=100) while True: d = feedparser.parse(OSM_CHANGES_RSS, etag=etag, modified=modified) modified = modified etag = d.etag sql = [] for e in d.entries: if e.id not in ids: ids.append(e.id) # u'45.2126441 -0.3701032 45.2126441 -0.3701032'
def setUp(self): self.client = CartoDB(CONSUMER_KEY, CONSUMER_SECRET, user, password, user)
# TO RUN # > virtualenv env # > . env/bin/activate # > pip install oauth2 # > pip install cartodb # # FILL IN THINGS BELOW # > python oauth_test.py from cartodb import CartoDB, CartoDBException import httplib2 import oauth2 as oauth if __name__ == '__main__': user = '' password = '' CONSUMER_KEY = '' CONSUMER_SECRET = '' cl = CartoDB(CONSUMER_KEY, CONSUMER_SECRET, user, password, 'simon') try: print cl.sql('select * from do_not_exist') except CartoDBException as e: print("some error ocurred", e) print cl.sql('select * from table')