PushMetrics comes with a powerful SQL editor that allows querying almost any SQL database.
It can be used to both receive data and write data to the database.
Query results data can be used in subsequent tasks.
The SQL Editor has the following inputs:
{{ parameter_1 }}
In the left sidebar, you can explore the database's contents like schemas, tables, and columns - making it easier to develop your SQL queries.
When hovering over a table name, you can also preview 100 rows of any table and copy a SELECT *
statement to your clipboard.
To execute a query, simply hit the Play button or use the keyboard shortcut ⌘ + enter
.
You can create dynamic queries using Jinja templating syntax.
This is useful to parameterize queries, use loops or if/else statements in your SQL statements.
You can easily preview the rendered query by clicking on the {{
button:
Query results are displayed below the SQL Editor.
</>
PushMetrics has a useful feature that keeps a history of your last query runs, so you can compare results between multiple run easily.
You can use both the query statement and the results data in other tasks using the following methods:
Method | Description |
---|---|
query_name |
returns the query as a string Example Usage: Example Output: |
.data |
returns the most recent query result as a dictionary Example Usage: Example Output: |
.data[row_index] |
returns a single row of the most recent query result Example Usage: Example Output: |
.data[row_index].column_name |
returns a single cell value of the most recent query result Example Usage: Example Output: |
.export(filename, file_format='csv', csv_delimiter=' , ' , public=false) |
generates a .csv or .xlsx file from the most recent results and returns a secure file URL. The file can be made public. Options: Example Usage: Example Output: |