Call to Socrata database returns invalid syntax

40 Views Asked by At

When I try this url in a browser, it returns json data without a problem:

https://data.cityofgainesville.org/resource/gvua-xt9q.json?$where=report_date between '2015-01-10' and '2015-12-13'

But when I try to make the same call through Python:

response = requests.get('https://data.cityofgainesville.org/resource/gvua-xt9q.json?$where=report_date between '2015-01-10' and '2015-12-13')

data = response.json()

data = json_normalize(data)

data = pd.DataFrame(data)

... it returns a syntax error. Why would it work in a browser but not with a call from Python?

1

There are 1 best solutions below

0
Tom Schenk Jr On

Appears to be a couple of issues. As noted in the comment, looks like you have a mismatched set of quotations.

Second, when the error is corrected, there is another error dealing with the SSL certificate. This is unrelated to the query syntax but something wrong either with requests library or the SSL certificate itself.

Nevertheless, it appears that changing to http:// instead of https:// will work. So, give this a try:

response = requests.get("http://data.cityofgainesville.org/resource/gvua-xt9q.json?$where=report_date between '2015-01-10' and '2015-12-13'")