这是我的 Jupyter 演示代码:
from redash_dynamic_query import RedashDynamicQuery
import pandas as pd
import json
redash = RedashDynamicQuery(
endpoint='http://demo.redash.io/',
apikey='ejsbcH7u2gqCzKjgjltaJhBfrRqkSuTCy1pi5Lur',
#取得したいデータソースIDを設定
data_source_id=1
)
#取得したいクエリIDを設定
query_id = 8174
bind = {
"start_date": '2017-01-01T00:00:00',
"end_date": '2019-12-31T23:59:59',
}
#redashのクエリ結果を取得
result = redash.query(query_id, bind)
res = result['query_result']['data']
#jsonを整形
res_format_json = json.dumps(res, indent=4, separators=(',', ': '))
print(res_format_json)
但我得到了这个错误:
ExceptionTraceback (most recent call last)
<ipython-input-19-6bc390f7a5bf> in <module>
15
16 #redashのクエリ結果を取得
---> 17 result = redash.query(query_id, bind)
18 res = result['query_result']['data']
19
/opt/conda/lib/python3.7/site-packages/redash_dynamic_query/__init__.py in query(self, query_id, bind, as_csv)
26
27 # post query result
---> 28 response = self._api_query_results(self._build_query(query_id, query_body, query_data_source_id))
29 if 'query_result' in response:
30 return response
/opt/conda/lib/python3.7/site-packages/redash_dynamic_query/__init__.py in _api_query_results(self, query_string)
90 )
91 if response.status_code != 200:
---> 92 raise Exception('query_results failed. [%d]' % response.status_code)
93
94 return response.json()
Exception: query_results failed. [404]
我是不是设置错了。我只是基于 redash_dynamic_query 库的原始文档。感谢您的阅读,如果您有答案,请帮帮我。