Sql Transform

The Sql transform enables you to run Sql commands on heterogenous data sources. For example, imagine you have a JSON array loaded from query sql0, where each element contains the property Country. You have an input field, input0, which has a text property that the user types in.

You would like to run a transform that selects all rows from the sql0 datasource where the Country field contains the user input substring.

To do so, insert the following for the SQL Query property: Select * from {{queries.sql0.data}} where Country like "%{{data.input0.text}}%".

2590

🚧

You can only have expressions like "%{{data.input0.text}}%" for the client side SQL transform.

For a standard SQL query, if you want to surround an input with wildcards or process it, you'll have to have wrap the transformation inside an Inline Javascript component and reference its output instead to prevent SQL injection.

📘

What are {{}} good for

All component properties are stored in a global key value store that other components in the app are able to access. You are able to reference other components using javascript dictionary terminology.

Based on Django's templated {{}} syntax, the special {{}} expression allows you to substitute in values from one set of objects in your application to another. For example, in the SQL Query, we reference the text property of the Input component with identifier input0. As all data components are stored under the global data key, to reference this component, we would write {{data.input0.text}}.

For a full overview of all the sql commands you can run, please see https://github.com/agershun/alasql/wiki/Sql.