LoginSignup
14
6

More than 5 years have passed since last update.

Redash APIで動的クエリ発行するモジュール

Last updated at Posted at 2017-02-25

Redashで動的にパラメータ指定してクエリ発行したかったんですが、なんとAPI一発では出来ないということが発覚…

issue には上がっているのでそろそろ実装されそうですが、今すぐ欲しかったのでモジュール書いてみました。
https://github.com/toritori0318/redash-dynamic-query

使い方

SYNOPSYSそのままです。

from redash_dynamic_query import RedashDynamicQuery

redash = RedashDynamicQuery(
    endpoint='http://myredash-host',
    apikey='secret_apikey',
    data_source_id=2
)

query_id = 111
bind = {
    "start_date":  '2017-01-01T00:00:00',
    "end_date":  '2017-01-01T23:59:59',
}
result = redash.query(query_id, bind)
print result['query_result']['data']

query_idとbind変数指定して実行すると結果取得できます。うぇーい

14
6
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
6