Available in workspaces version 1.4.1 and later
Use the SQL cell option in notebooks in workspaces to query supported SQL-based Dash Enterprise data sources. SQL cells run a query on a data source and save the results as a Pandas DataFrame to a Python variable.
To query a SQL-based data source:
Go to the Data Sources menu:
<img>
Select Query in Notebook from the menu options beside a table on a SQL-based data source and then select the notebook you want to use.
<img>
This generates a cell for querying the data source and has a basic SQL query pre-populated.
You can also create a blank cell directly in the notebook:
<img>
From a blank cell, select a data source, write your SQL query, and run the cell to get started.
<img>
SQL cell supports reading data from data sources using SELECT. INSERT and UPDATE aren’t supported.
When you run a SQL cell, the results returned from the data source are saved as a DataFrame to a variable. The variable name is randomly generated for each cell, but can be updated via the Var field in the top-right corner of the cell:
<img>
To use the returned DataFrame in a code cell in the notebook, use the variable name displayed in the SQL cell’s Var field. For example, to use the variable from the query run in the previous screenshot in a plotly.express
scatter chart:
import plotly.express as px
fig = px.scatter(df_0m6y, x="sepal_width", y="sepal_length")