SQL Queries

PushMetrics comes with a powerful SQL editor that allows querying almost any SQL database.

Query results data can be used in other tasks.

Row Limit: PushMetrics currently supports query results with a maximum of 100k rows. This limit will be applied even if no limit is present in your query. Contact us if you need a higher limit.

Creating SQL Queries

SQL Editor

The SQL Editor has the following inputs:

  • Query Name: Used for referencing the query and its results
  • Database Connection: Select which database the query should run against
  • SQL code: Write your SQL statement. Supports Jinja templating, e.g. a parameter value can be used inside the SQL statement like this: {{ parameter_1 }}
  • Limit: Visual interface to apply row limits to queries

Data Explorer

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.


Jinja Preview

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

Query results are displayed below the SQL Editor.

  • You can sort columns
  • You can create a chart from the results data
  • You can check the details of the run </>
  • You can download the data as CSV or XLSX

Results History

PushMetrics has a useful feature that keeps a history of your last query runs, so you can compare results between multiple run easily.

Referencing Queries and Results Data

You can use both the query statement and the results data in other tasks.

Function Description Example Usage Example Output
query_name returns the query as a string {{ query_1 }} SELECT * FROM my_table
.data returns the most recent query result as a dictionary {{ query_1.data }} [{'category': 'Furniture', 'city': 'Henderson', 'country': 'United States'}, {'category': 'Furniture', 'city': 'Henderson', 'country': 'United States'}]
.data[row_index] returns a single row of the most recent query result {{ query_1.data[0] }} {'category': 'Furniture', 'city': 'Henderson', 'country': 'United States'}
.data[row_index].column_name returns a single cell value of the most recent query result {{ query_1.data[0].category }} Furniture