I have access to a Redshift production database via redash.
Is there a way to extract data via redash APIs from an external python environment.
If so, Kindly suggest on the steps.
Avishek
I have access to a Redshift production database via redash.
Is there a way to extract data via redash APIs from an external python environment.
If so, Kindly suggest on the steps.
Avishek
You can use the query_results API. There is an example in our redash-toolbelt library.
That said, if you are going to access from Python already you might as well connect directly from Python as Redash will introduce a significant amount of serialisation overhead.
Thanks for the help Jesse. We do not have the db credentials. The db is connected through Redash after the superadmin has entered the credentials.
Under these circumstances can the above suggested method help, where we use the Redash API to access the query ?
It also seems from the above git link shared that, we would need to save the query in redash first in the redash platform. If there’s a way to insert the query in the python env without saving in redash, kindly help with the same as well.
Additionally, if there are any extra resources to help understand this better, would really help if those are shared as well.
Thanks again,
Avishek
Hmmm sounds like an odd setup. We don’t recommend super-admin credentials be used with Redash anyway. Only read-only credentials with access to the data you wish to query. I strongly recommend you connect to the database natively versus using Redash as your gateway.
You can execute arbitrary queries using the Redash API by making a POST to the /query_results
endpoint where the JSON request body includes a data_source_id
, max_age=0
, and query
contains the query text. This will return a job execution object which you can poll until the execution completes.
Your use case is not recommended for Redash, however.