Skip to content

Raw SQL connector

With Serenytics, you can use data from your SQL server without any SQL skills using the default SQL connector for you database. But in some advanced use cases (or if you have existing SQL queries to re-use), you may want to write your own SQL code.

This is what this connector is dedicated to. You can write a SQL query and the output of this query will be available as a datasource for your dashboard (or for a data pipeline).

Use variables

You can inject variables in your query using the double curly brackets syntax.

Here is an example:

select * from customers where country='{{country}}'

In this query, country is a variable that must be defined. You can use the Datasource variables field just below the SQL editor to provide values (as a JSON dictionary). This is especially usefull for tests purpose. Here is an example:

{"country": "France"}

When the datasource is queried from a dashboard, variables defined in this dashboard will be passed to the query. Values from the dashboard will overwrite values defined as Datasource variables in the datasource.

You can configure a dynamic filter to store the value selected by the user in a variable (using the option Store selected value as variable in its config). This variable will be passed to the SQL query when the filter is changed by the user.

If you are using an embedded dashboard into your app, you can also use the variables dynamically passed to the dashboard in your query.