1

Using urllib to make my API call to CartdoDB (per Andrew Hill's example here). I'm getting a successful '200' in response, and can get the script to print out my JSON response, but my problem is the map doesn't update after making this SELECT statement. Am I missing a step in order for that to happen?

Thanks!

Ben


import urllib
import urllib2
import json

username = '[MY USER NAME]'
apikey = '[MY API KEY]'
query = 'SELECT * FROM map_census_acs2012_ct WHERE (population > 8000 AND population <= 26908)'

url = "https://[MY USER NAME].cartodb.com/api/v1/sql"

# prams object that holds our api key and query.
params = {
    'api_key' : apikey,
    'q'       : query  
}

req = urllib2.Request(url, urllib.urlencode(params))
res = urllib2.urlopen(req)
res.getcode()
Community
  • 1
  • 1
bdkauff
  • 225
  • 3
  • 13
  • 1
    The map itself is updated using Javascript, is it not? So, a server-side Python query will not automatically update the client-side map view. – John Powell Nov 25 '14 at 23:41
  • That's what I was afraid of, but I think you're probably right... – bdkauff Nov 27 '14 at 13:53

1 Answers1

2

as John Barça says, in order to properly update your map in the client-side with the new data you'll need to use the CartoDB.js API.

ps: I'm adding the comment as an answer in order to be able to mark it as valid.

Community
  • 1
  • 1
matallo
  • 36
  • 1