Solved

Get SQL text from dashboard tile

  • 26 August 2021
  • 1 reply
  • 62 views

It is possible using looker API3 to retrieve sql query (text) that has been generated by tile(look) in dashboard?

I want to get field sql (like in sql_query method) but only forqueries that was already been run.

So basically having query_id I want query method to return sql query textas a field as well. Is it possible in any way?

icon

Best answer by Eric_Lyons 26 August 2021, 15:30

View original

This topic has been closed for comments

1 reply

Userlevel 4
Badge

You can do something like this:
 

from looker_sdk import methods, models40
sdk = looker_sdk.init40()

elements = sdk.dashboard_dashboard_elements(dashboard_id="970")
for element in elements:
query = sdk.run_query(element.query_id,result_format="sql")
print(element.title)
print(query)

One of the result formats for run query is sql.