Retrieve SQL Runner query results

api

(Alson Yap) #1

Hi all, I noticed that the only available functions for SQL Runner via API are “Get SQL Runner Query” and “Create SQL Runner Query”. Is it thus not possible to run a SQL Runner query and get its results?


(diego.campos) #2

Hello Alson,

This is not possible at the moment. You can create a SQL runner query task, but there is no API to fetch the results of that query.

We have a case opened with Engineering in order to add this in upcoming releases.

Please let us know in case you have any further question.

Thanks.


(Alson Yap) #3

That’d be great, thanks Diego!


(Zander) #4

Was there any further action to this?


(will.adams) #5

Hey @awmatheson, we don’t have a release date for this feature but it has had a good bit of interest. I’ll let the engineering team know you’re also looking to have this functionality as well.


(Joanna Kochel) #6

My workaround here is that from SQL runner I click “Explore” and then I get slug id from link and run it from API using query_for_slug and then run_query :slight_smile:


#7

Hi,

Once a SQL runner query task has been made, is there any API link (maybe using the slug?) to get the results from that query?


(Grace Gee) #8

@Joanna_Kochel Which Looker API were you using and what parameter did you put into run_query? I tried getting the slug and then run_query with a python API (https://github.com/llooker/python_sdk) and slug ID as well as the SqlQuery object (https://github.com/llooker/python_sdk/blob/master/docs/SqlQuery.md) to no avail =’(


(Jonathan Hester) #9

Hey grace_gee & marcoppenheimer,

Thanks for voicing your feedback and questions on this topic! This is something that has a lot of interest which our engineers are aware of and I have let them know your feedback on this!

Joanna’s approach is a great way to go in the meantime, what I would suggest and Joanna can correct me if she has an easier approach is the following:

  1. Generate your query using SQL runner
  2. Select the cog button beside ‘Run’ and choose ‘Explore’
  3. This will open up your query/results in an explore page
  4. Copy the string after the url param ‘qid=’ in your URL
  5. Open up the Looker API and click on ’ [Query : Run and Manage Queries]’
  6. Open up [SDK][query_for_slug(slug)] and paste in the copied url param string where it asks for slug. This will generate a response body and the first line should be an ID like this example: ( "id": 120164,)
  7. Open up [SDK][run_query(query_id, result_format)] and add the ID in query_id param and then in the result_format you can add csv.

Here are screenshots of some dummy data in my SQL Runner explore and then the same data in the API after following the above steps!


Hope this helps guys! :slight_smile:
Jay