Skip to content

SQL Query to storage

With this automation, you can store the result of an SQL Query into a Serenytics storage.

Basic Configuration

The configuration is straightforward. You need to provide the credentials to connect to your database.

Then, you can write any SQL query in the editor. The final step is to run the query in the Execution tab.

Options

Quotes all string fields when reloading data

For performances reasons, the result of your SQL query is stored in a CSV file before being reloaded. The default settings will ensure the CSV file is correct and can be reloaded in the destination storage. But in some corner-cases (e.g. if some of your fields contain a Carriage Return character without any LineFeed character), your automation may fail. If you enable this Quotes all string fields when reloading data option, this type of issue will be fixed. But the automation is usually 15% slower.

Force types

By default, the Serenytics engine will auto-detect types. In some corner-cases, you may want to force the types (e.g. when the type detection fails). This field lets you manually force the types of the columns in the output storage.

Example:

{"mycolumn1": "int32", "Mycolumn2": "float64", "Mycolumn that should be a date": "datetime"}

The provided types must be one of int32, int64, float32, float64, datetime, str, str(X).

  • int64 is an integer on 64 bits (8 bytes), also referred as BigInt in some databases.
  • float64 is a double precision float.
  • str(X) is a varchar column with length X.

Which column name to use

You may have noticed that the output storage column names may be slightly different from your sql query column names. When you specify the forced type of a column in this automation, you need to use the column name of the SQL query, and not the column name in the output storage. For example, if you have a date of creation column in your query, the output column name will be date_of_creation in the storage. In the Force types field, you need to use the date of creation name.