Redash
The Redash class allows you to interact with a Redash server to refresh queries and get query results.
- class parsons.redash.Redash(base_url=None, user_api_key=None, pause_time=3, timeout=0, verify=True)[source]
Instantiate Redash Class
- Args:
- base_url: str
The base url for your redash instance (excluding the final /)
- user_api_key: str
The user API key found in the User’s profile screen
- pause_time int
Specify time between polling for refreshed queries (Defaults to 3 seconds)
- verify: bool
For https requests, should the certificate be verified (Defaults to True)
- Returns:
Redash Class
- get_fresh_query_results(query_id=None, params=None)[source]
Make a fresh query result and get back the CSV http response object back with the CSV string in result.content
- Args:
- query_id: str or int
The query id of the query
- params: dict
If there are values for the redash query parameters (described https://redash.io/help/user-guide/querying/query-parameters e.g. “{{datelimit}}” in the query), then this is a dict that will pass the parameters in the POST. We add the “p_” prefix for parameters, so if your query had ?p_datelimit=…. in the url, you should just set ‘datelimit’ in params here. If you set this with REDASH_QUERY_PARAMS environment variable instead of passing the values, then you must include the “p_” prefixes and it should be a single url-encoded string as you would see it in the URL bar.
- Returns:
Table Class
- get_cached_query_results(query_id=None, query_api_key=None)[source]
Get the results from a cached query result and get back the CSV http response object back with the CSV string in result.content
- Args:
- query_id: str or int
The query id of the query
- query_api_key: str
If you did not supply a user_api_key on the Redash object, then you can supply a query_api_key to get cached results back anonymously.
- Returns:
Table Class
- classmethod load_to_table(refresh=True, **kwargs)[source]
Fast classmethod so you can get the data all at once: tabledata = Redash.load_to_table(base_url=’https://example.com’, user_api_key=’abc123’,
query_id=1001, params={‘datelimit’: ‘2020-01-01’})
This instantiates the class and makes the appropriate query type (refresh or cached) based on which arguments are supplied.
- Args:
- base_url: str
The base url for your redash instance (excluding the final /)
- query_id: str or int
The query id of the query
- user_api_key: str
The user API key found in the User’s profile screen required for refresh queries
- query_api_key: str
If you did not supply a user_api_key on the Redash object, then you can supply a query_api_key to get cached results back anonymously.
- pause_time int
Specify time between polling for refreshed queries (Defaults to 3 seconds)
- verify: bool
For https requests, should the certificate be verified (Defaults to True)
- refresh: bool
Refresh results or cached. (Defaults to True unless a query_api_key IS supplied)
- params: dict
For refresh queries, if there are parameters in the query, then this is a dict that will pass the parameters in the POST. We add the “p_” prefix for parameters, so if your query had ?p_datelimit=…. in the url, you should just set ‘datelimit’ in params here.
- Returns:
Table Class