redash python api client
$ pip install redash-py
set environments REDASH_API_KEY
and REDASH_SERVICE_URL
(e.g. https://redash.your.domain
).
from redash_py.client import RedashAPIClient
# call __init__ without Any arguments, use environments.
client = RedashAPIClient()
or Explicitly specify.
from redash_py.client import RedashAPIClient
client = RedashAPIClient(
api_key='your redash admin api key',
host='https://redash.your.domain)'
)
Create new query.
res = client.create_query(
name='query name',
data_source_name='data source name',
query='select * from your_table;',
description='your query description',
is_publish=True, # create and publish or draft
)
If the QueryId exists, overwrite it. Create Query if not.
res = client.update_or_create_query(
query_id=1,
name='query name',
data_source_name='data source name',
query='select * from your_table;',
description='your query description',
is_publish=True, # create and publish or draft
)