0
我想從數據庫中查詢,我試圖查找正確的方式來格式化SoQL字符串,但我失敗了。我嘗試以下方法:從蘇打數據庫查詢使用Socrata client.get在Python
from __future__ import division, print_function
from sodapy import Socrata
import pandas as pd
import numpy as np
client = Socrata("data.cityofchicago.org", None)
df = client.get("kkgn-a2j4", query="WHERE traffic > -1")
並且收到一個錯誤消息說它Could not parse SoQL query "WHERE traffic > -1" at line 1 character 1
。如果我這樣做,但是,它的工作原理:
from __future__ import division, print_function
from sodapy import Socrata
import pandas as pd
import numpy as np
client = Socrata("data.cityofchicago.org", None)
df = client.get("kkgn-a2j4", where="traffic > -1")
但我想知道如何得到查詢參數工作,所以我可以用更復雜的查詢。具體來說,我想嘗試查詢traffic > -1
和BETWEEN '2013-01-19T23:50:32.000' AND '2014-12-14T23:50:32.000'
。
只是出於好奇,你知道你將如何編寫查詢字符串獲得相同的結果? – jtorca
對不起,剛注意到這個!您可以將'$ query'寫爲:'SELECT * WHERE traffic> -1 AND last_update BETWEEN'2013-01-19T23:50:32.000'AND'2014-12-14T23:50:32.000'' – chrismetcalf