Work with SQL cells
DataSpell allows you to use SQL cells to query data sources in Jupyter notebooks and automatically save query results to pandas dataframes.
Enable the Database Tools and SQL plugin
This functionality relies on the Database Tools and SQL plugin, which is bundled and enabled in DataSpell by default. If the relevant features aren't available, make sure that you didn't disable the plugin.
Press Ctrl+Alt+S to open the IDE settings and then select.
Open the Installed tab, find the Database Tools and SQL plugin, and select the checkbox next to the plugin name.
Query a database
Select SQL in the cell type selector in the notebook toolbar.
Select the data source from the list of connected data sources.
To add a new data source, follow the steps below:
- Add new data source
Open the Database tool window by clicking Database or go to in the main menu.
Do one of the following:
Click New in the Database tool window.
Select Data Source and choose the database type.
Configure the connection settings in the Data Sources and Drivers dialog.
Set the name of the variable in which the result of the SQL request will be stored as a dataframe.
Enter the SQL statement and execute it by running the SQL cell.
To run the SQL cell, do one of the following:
Right-click on the SQL cell and select Run cell from the context menu.
The query result will be shown in the output and saved to the dataframe.
Continue to work with the SQL variable in the code cells.