Use SQL cells to query attached databases and retrieve data as tabular data objects. SQL cells are the recommended method of work with SQL when activating reactive mode.
Query a database in an SQL cell
Create an SQL cell:
Go to New SQL cell for the attached database that you want to use.and click
Hover over the bottom border of a cell and select. You will be prompted to select the required database if you you have more than one database attached.
Enter an SQL statement.
Run the query (Run icon or Ctrl + Enter shortcut). The result set will be shown in the output and saved to a tabular data objects (for example, DataFrame).
(Optional) To rename the data object, click the object name next to RESULT SAVED TO on the SQL toolbar.
SQL cells: example
Below is an example of two SQL cells used to work with a Snowflake database.
Parameterized SQL queries
You can use Python variables in your SQL queries in Datalore. Such queries can be reused repeatedly with different values, which helps make your reports more interactive.
Supported variable types are: strings, numbers, booleans, and lists. Make sure you place your variable inside
Parameterized SQL query example
In the image below, you can see two cells:
Dropdown interactive control cell using the
SQL cell where the value in payment column equals the
methodvariable value selected from the dropdown list.
SQL cells in trial mode
For Community plan users, SQL cells are available in trial mode for a period of 30 days. Within the trial period, you can create and attach an unlimited number of database connections and use an unlimited number of SQL cells to query them.
You can start the trial in one of the following ways:
Click Start trial in the notification window that you can see when you choose to add an SQL cell.
Click Start trial on the banner that you can see when you open Attached data.
In the Attached data pane, you are notified when your trial period expires.