Run queries using Python

Hi All,
I have certain queries in local excel sheet, which i need to run on redash and store the result in back in a new sheet. The reading and writing i can figure out but how can i run queries using python and get the result?

Has anyone tried it?(m sure someone has) I tried installing redash-python package and have successfully done the authentication. How to move ahead is what i’m looking for.

Any pointers would be helpful.

Thanks,
Auto-user

You can check this code:

there are 2 apis

  • one to get the job started
  • one to fetch the result

First and foremost thanks @xavier-d for the quick response. This solution fantastic, however i’m more keen on sending the actual query as function argument rather than the query id. is that possible?

query must be saved to be executed using the queryID
so either updating or creating a new query in order to get the id, I don’t see how to do it.

I don’t know what you want to perform, but creating sheets in Excel is not the right solution :wink:

The sheet is the requirement as it gets sent in email to stakeholders(some of whom do not have access)
The reason I’m trying to put the queries directly is because i wont have fix set or queries to run every time. They will keep changing, hence taking them from an input sheet.
i checked redash-python for execute_query and get_query_result, looked good, but couldnt get much on them.

anyhow https://redash..io/queries/2938/results is throwing a 405 Method Not Allowed error for POST. if a do a get i see a JSONDecodeError