damienzeng73 / redash-api-client Goto Github PK
View Code? Open in Web Editor NEWRedash API Client written in Python
License: MIT License
Redash API Client written in Python
License: MIT License
For example, for create_query
:
It is probably good that the payload always contains a few parameters (e.g., data_source_id
, name
, etc...), but what about all other potential (and useful) parameters? For example tags
, etc, Using kwargs
would be a great way to make your API much more general.
For example for create_query
:
def create_query(self, ds_id: int, name: str, qry: str, desc: str="", with_results: bool=True, **kwargs):
payload = {
"data_source_id": ds_id,
"name": name,
"query": qry,
"description": desc,
**kwargs
}
res = self.post('queries', payload)
if with_results:
self.generate_query_results(ds_id, qry)
return res
Then you can use it with
redash.create_query(1, "my query", "select 1 from table", "description", with_results=False, tags=["mytag"], options={} )
If you remove options
(i would) that would be a breaking change, so that's probably your decision.
But all that would be very easy to add that to all create_XXX
functions.
When using create_visualizations() with some kind of visualizations type (eg: counter, funnel, etc), the API gives errors regarding x and y axis, even when they are not supposed to be given for that kind of visualizations.
https://github.com/damnee562/redash-api-client/blob/master/redashAPI/client.py#L220
I think Auto Detect is easier to use than Category.
For Auto Detect, specify -
.
Can I change it if there is no special reason?
Currently there is no ability to set the parameterMappings field when adding a widget to a dashboard (i.e. setting whether the parameter is a dashboard or widget-level parameter) with the add_widget function. I would propose the attached changes to the function to add that capability.
add_widget.txt
Can you share an example of how to pass a parameter to the query? This is done using the {{ }}
in the UI.
Hi,
I am using Redash.generate_query_result to fetch data from Redash.
It behaves randomly that sometimes it gets the result and sometimes throws an error with Status: 2. Attaching screenshot.
The same query runs in Redash successfully hence, no issues with server.
Currently using Python's Try, Exception to complete the job, but it sometimes take forever to execute.
Is it a known issue? What can be the possible reasons for it and what can be the solution?
Hey,
is there any max payload that someone can retrieve using the API you have created?
I have been using the library and have the following issue:
We define a start_date and an end_date:
The weird thing is that the query runs ok when the start_date is 2022-06-01 00:00:00 but when the start_date is 2022-05-01 00:00:00 the response you get is the following:
File ~/miniconda3/envs/opap-kpis/lib/python3.9/site-packages/redashAPI/client.py:125, in RedashAPIClient.query_and_wait_result(self, ds_id, query, timeout)
121 raise Exception('Polling timeout.')
123 time.sleep(0.2)
--> 125 return self.get(f'query_results/{query_result_id}')File ~/miniconda3/envs/opap-kpis/lib/python3.9/site-packages/redashAPI/client.py:18, in RedashAPIClient.get(self, uri)
15 res = self.s.get(f"{self.host}/api/{uri}")
17 if res.status_code != 200:
---> 18 raise Exception(f"[GET] /api/{uri} ({res.status_code})")
20 return resException: [GET] /api/query_results/2196159 (502)
Also I have noticed the same behaviour when adding some columns to a query that is running ok.
I was thinking that this is due to a max payload or a maximum number of lines the redash_api can fetch.
I should also mention here that the query is running on the redash client we have set up on a Kubernetes cluster.
Could you please look into this?
Thanks in advance!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.