# Develop with Notebooks

Prototyping applications or analyzing via notebooks in SingleStore Helios follows the same general principles as developing with notebooks in general.

To get started, connect to a data source.

## Connect to Data Sources

SingleStore Helios supports internal and external data sources. Internal data sources are databases that exist within your workspace. An external data source could be an AWS S3 bucket, for example.

## Connect to a SingleStore Data Source

Once you select a workspace, you can access all of the databases attached to that workspace. You cannot connect to databases that are not attached to the workspace you are using.

You can specify a default database for your notebook, eliminating the need to specify the database context every time you make a query on that default database. To set a default database, select a database from the drop-down menu.

No default database specified:

![A workspace with no specified database.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt87ebd5c0607eb207/6a44f1326bd4b0ebe453493f/notebook_defaultdbunset-jF1nJ1.png)

Default database specified:

![A workspace with a specified database.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/bltfe783545afc22389/6a44f209a56c88ea57974600/notebook_defaultdbset-JoxkAi.png)

## Connecting via SQL

To connect to the default database, you do not need to pass any database context to query that database:

```sql
%%sql
SELECT * FROM mytable;
```

To connect to a non-default database, you will need to specify the database in your query:

```sql
%%sql
USE mydatabase;
SELECT * FROM mytable;
```

You can also use "dot" notation:

```sql
%%sql
SELECT * FROM mydatabase.mytable;
```

## Connecting via Python

When connecting via Python to the default database, use the predefined connection string variable, `connection_url`:

```python
from sqlalchemy import *
db_connection = create_engine(connection_url)
```

You can then use that connection string (`db_connection` above) to connect to SingleStore. Here's an example of creating a table using that connection string:

```python
query1 = 'create table people (filename varchar(255), vector blob, shard(filename))'
with db_connection.connect() as conn:
    conn.execute(text(query1))

```

When connecting to other databases, use the following method where user (`connection_user`), password (`connection_password`), host (`connection_host`), and port (`connection_port`) are already defined based on the workspace you selected.

```python
from sqlalchemy import *
database_name = 'mydatabase'
db_connection_str = "singlestoredb://"+connection_user+":"+connection_password+"@"+connection_host+":"+connection_port+"/"+database_name
db_connection = create_engine(db_connection_str)
```

You can then use that connection string (`db_connection` above) to connect to SingleStore:

```python
query1 = 'create table people (filename varchar(255), vector blob, shard(filename))'
with db_connection.connect() as conn:
    conn.execute(text(query1))

```

## Connect to an External Data Source

SingleStore Helios lets you control which endpoint to access from notebooks to provide secure outbound access to trusted resources. 

By default, connections are limited to SingleStore databases; however, you can enable and disable connections to other external endpoints via the allowlist.

Only users with the **Organization Owners** role can add external connections.

When trying to access an external endpoint from a notebook that is not in the allowlist, you should see the following warning:

![](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt54dada4501343dbe/6a44f23abd4075d8988cdfb0/notebook_externalendpoint-7FDguw.png)

To fix this issue, select **Add to Firewall** and then select **Save**. The external connection is automatically added into the allowlist. The notebook cell will be executed.

![Adding external endpoint in FQDN allowlist.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt1776188a6bcc031f/6a44f22cdc49d6953495cbee/notebook_addexternalendpoint-uRL3Id.png)

If you do not have access due to your role, your organization owner can manually add or remove the external endpoint using the following steps:

![Add external connection to firewall.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt9de5e560f2d268a7/6a44f0bc8e1cf1ccece589ce/Screenshot_2025-11-18_at_12_15_42_PM-rObtTk.png)

1. In the left navigation, select **Editor**.

2. Select the **Firewall** tab in the main window.

3. Select **Edit** to add new endpoints:

   ![The Edit FQDN Allowlist dialog with Add FQDN button and Add Suggested FQDN button, with Cancel and Save buttons.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt64ae0bdac5a4457b/6a44f12ea56c88c2979745fa/notebook_edit_fqdn-3tZpNJ.png)

4. In the Edit Allowlist dialog, you can add a Fully Qualified Domain Name (FQDN) or select from a list of suggested FQDNs (for example pypi.org, github.com, or \*.s3.\*.amazonaws.com).

   You can provide wildcard access to an endpoint by using the `*` character. The wildcard character represents 0 or more valid DNS characters, except for '.'.

   `*.singlestore.com` matches `docs.singlestore.com` but not `singlestore.com` because it only matches up to the '.' character. `ex*le.com` matches example.com but not `examp-site.com`.

   For example, to access any AWS S3 endpoints, you can use the following syntax:  \*.s3.\*.amazonaws.com.

5. Select **Save**.

To remove a connection select the Trash icon next to the connection in the Edit FQDN Allowlist dialog.

## Manage Cells

Use the same commands and techniques you use with most other Python based cells in notebooks.

## Cell Types

A notebook cell can be one of these types:

* **Markdown**: lightweight markup language used to add formatting to plain text. More information [here](https://jupyter-notebook.readthedocs.io/en/stable/examples/Notebook/Working%20With%20Markdown%20Cells.html).
* **Python**: language supported is Python 3.
* **SQL**: language supported is SQL (for SingleStore).

Specify the cell type by selecting a cell and choosing a type from the drop-down menu:

![Specify the cell type as Python from the drop-down list.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blte4abd6708a175fda/6a44f2234774366c12d3cf36/notebook_cell-uuCqNs.png)

## Run a cell

Execute/run a cell via keyboard shortcut (**Shift+Return/Enter**) or by selecting the run (play button) icon at the left of the notebook cell, or by selecting **Run Selected Cell** option from the **Run** menu in the toolbar.

![Select play button to run the cell.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt240bdb057219dde7/6a44f1281510350faa200bf1/notebook_cell_run-V8IFJc.png)

## Run Multiple Cells

Execute/run multiple selected cells using the following options from the **Run** menu in the toolbar:

* Run Selected Cell and All Below
* Run All Above and Selected Cell
* Run All Cells
* Restart and Run All Cells

## Manipulating Cells

When you select a cell, some icons for basic cell manipulation appear:

| Action     | Icon                                                                                                                                                                                                   | Description                                                                 |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------- |
| Add a cell | ![Icons for adding a cell above or below the current cell.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt449ebf8b1af3cec4/6a44f23bddbfd13402908166/notebook_add_up_down-O0OsAB.png) | Add a new cell above or below the selected cell.                            |
| Move       | ![Arrow up and down icons.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt116eaaebea916f46/6a44f12f8d5fe3e828a6a3c3/notebook_up_down-3Jt4bj.png)                                     | Move the selected cell up or down.                                          |
| Copy       | ![](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt580bc028856b8c88/6a44f273cbd14e0558a1083a/notebook_copy-3cl4Si.png)                                                                | Copy the selected cell.                                                     |
| Duplicate  | ![Duplicate Icon](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/bltefded23f506c0dc9/6a44f12252835c3822127965/notebook_dup-qXfopp.png)                                                   | Duplicate the current cell and place it immediately below the current cell. |
| Delete     | ![Trash Can icon for Delete.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt0d83795fff381e20/6a44f1b94887b8a72f4225e3/notebook_delete-omHsbb.png)                                    | Delete the selected cell.                                                   |
| Ask SQrL   | ![Ask SQrL icon](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt5d37890ebb249f60/6a44f277a7eb581fcca629f6/notebook_ask_sqrl-JQ5qOk.png)                                               | An AI-powered co-pilot (SQrL) answers questions.                            |

For more options, right-click/control-click on a cell to open the cell context menu.

From the context menu, you can perform additional cell functions, such as split and merge.

Keyboard shortcuts exist for most common tasks as well.

![Right-click/control-click on a cell to open the cell context menu. Keyboard shortcuts for manipulating cells](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt6966c660ef0b8c22/6a44f12d917f296ba0f2f59c/notebook_context2-tm0jnK.png)

## Manage Cell Inputs and Output

Right-click/control-click on a cell to open the cell context menu.

![Right-click/control-click on a cell to open the cell context menu to manage cells.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt9bf24333455020d1/6a44f13b7dad69442c03a7e4/cell_context_menu-zjHL4v.png)

An additional option **Format SQL Cell** is available when the selected cell is using the SQL language (via the `%%sql` magic command or the SQL cell).

You can also show/hide cell output by selecting the vertical bar (purple) next to the output. Before:

![Example of a vertical "bar" alongside a cell's output, expanded below the cell.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt5927580954ee4421/6a44f270bd4075382f8cdfc3/notebook-hide-results-b-wpKGEK.png)

After selecting the bar:

![An example of the truncated vertical "bar" after the cell output is collapsed.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/bltbbd89d83ccf55a67/6a44f20b8d5fe3ecaaa6a3cf/notebook-hide-results-a-WAQcvQ.png)

## Use Multiple Languages

You can set the default language for notebooks to either SQL or Python3.

You can select the language for a cell via the toggle located above the cell:

![Cell type from the drop-down list above each cell.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt7fe89d531fe92035/6a44f2087b8777e9c9fdb2df/notebook_cell_types-USytmH.png)

## Python Cells

Python 3 is the default language for Python cells. See the [Python documentation](https://docs.python.org/3/index.html) for more information about using Python.

## SQL Cells

There are two options to write SQL in notebooks. The first involves selecting a cell type to be SQL. The following example shows how to specify a default database (mydatabase) and the syntax used to connect to another database (mydatabase2) for use in joins with an SQL cell:

```sql
USE mydatabase; -- the database to use by default
SELECT * from mytable mt1
INNER JOIN mydatabase2.mytable2 mt2 ON mt1.mycolumnid1 = mt2.mycolumnid2;
```

The next option is to use the SQL magic from within a Python cell. This gives you the ability to write SQL and Python code in a single block:

```sql
%%sql - switch the cell to SQL
USE mydatabase; -- the database to use by default
SELECT * FROM mytable mt1
INNER JOIN mydatabase2.mytable2 mt2 ON mt1.mycolumnid1 = mt2.mycolumnid2;
```

The results are displayed as a table.

You can also save and use the output from the calculation in an SQL cell (called `output_reviews` in this example) in another Python cell with the following options:

Using cell output - **Save result to**:

![Execute SQL commands using SQL cell type.](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/blt8d321418205d0269/6a44f13a8d5fe368a3a6a3c7/notebooks_usecelloutput-EDtLCT.png)

Or, using SQL magic:

```sql
%%sql output_reviews << -- switch the cell to SQL and specify the output as output_reviews

SELECT * FROM reviews
```

This output can then be used in other cells, etc. For example, in this example, `output_reviews` is used with Python as a dataframe:

```python
df = pd.DataFrame(output_reviews) 
```

## SQL Line

Use `%sql` to enable a single line of SQL in a Python cell:

```python
result = %sql USE s2_dataset_martech; SELECT * FROM offers GROUP BY customer LIMIT 10
```

Combine SQL and Python in the same cell:

```python
result = %sql USE s2_dataset_martech; SELECT * FROM offers GROUP BY customer
df = pd.DataFrame(result)
```

## Manage Libraries

SingleStore notebooks come with pre-installed libraries, and you can install additional libraries as needed.

## Pre-installed Libraries

Run the following command in a Python cell to see the list of pre-installed libraries:

```python
!pip list
```

## Install and Import Libraries

SingleStore supports libraries available from <https://pypi.org/> . This example shows how to install a library from the [Kaggle open dataset](https://pypi.org/project/opendatasets/).

```python
!pip3 install opendatasets
```

To update the version of a pre-installed library:

```python
!pip3 install plotly --upgrade
```

Once a library is installed, you can import library components and add an alias:

```python
import opendatasets as od
```

> **💡 Tip**: For better clarity, have one cell at the beginning of the notebook with all additional libraries to install and have a second cell listing the libraries to import. You can then collapse the two cells to remove clutter.

## Magic Commands

For a specific cell, to see all the supported magic commands:

```python
%lsmagic
```

For information about the full list of available magic commands:

```python
%quickref
```

Some helpful magic commands:

| Magic Command      | Description                                                      |
| ------------------ | ---------------------------------------------------------------- |
| %history           | View the log of the session activity for the notebook.           |
| %pinfo \<variable> | Details of the object stored in the specified variable.          |
| %time              | Show the time of execution of a Python or SQL statement.         |
| %who               | List all of the currently defined variables within the notebook. |

## Useful Shortcuts

There are two modes in a notebook: command and edit. Command mode is activated by pressing ESC. Edit mode is activated by pressing Enter.

## Command and Edit Mode Shortcuts

| Task                               | Mac             | Windows       |
| ---------------------------------- | --------------- | ------------- |
| Run the current cell, select below | Shift + Enter   | Shift + Enter |
| Run selected cells                 | Command + Enter | Ctrl + Enter  |
| Run the current cell, insert below | Option + Enter  | Alt + Enter   |
| Save and checkpoint                | Command + S     | Ctrl + S      |

## Command Mode Shortcuts

| Task                             | Mac                      | Windows                  |
| -------------------------------- | ------------------------ | ------------------------ |
| Enter edit mode                  | Enter                    | Enter                    |
| Select cell above                | Up                       | Home                     |
| Select cell below                | Down                     | End                      |
| Extend selected cells above      | Shift + Up               | Shift + Home             |
| Extend selected cells below      | Shift + Down             | Shift + End              |
| Insert cell above                | A                        | A                        |
| Insert cell below                | B                        | B                        |
| Cut selected cells               | X                        | X                        |
| Copy selected cells              | C                        | C                        |
| Paste cells below                | V                        | V                        |
| Paste cells above                | Shift + V                | Shift + V                |
| Move cell up                     | Ctrl + Shift + Up        | Ctrl + Shift + Home      |
| Move cell down                   | Ctrl + Shift + Down      | Ctrl + Shift + End       |
| Split cell                       | Ctrl + Shift + Minus (-) | Ctrl + Shift + Minus (-) |
| Delete selected cells            | D, D (press twice)       | D, D (press twice)       |
| Undo cell operation              | Z                        | Z                        |
| Redo cell operation              | Shift + Z                | Shift + Z                |
| Merge selected cells             | Shift + M                | Shift + M                |
| Merge cell above                 | Ctrl + Delete            | Ctrl + Backspace         |
| Merge cell below                 | Ctrl + Shift + M         | Ctrl + Shift + M         |
| Save and checkpoint              | S                        | S                        |
| Change the cell type to Code     | Y                        | Y                        |
| Change the cell type to Markdown | M                        | M                        |
| Scroll notebook up               | Shift + Space            | Shift + Space            |
| Scroll notebook down             | Space                    | Space                    |
| Find                             | Command + F              | Ctrl + F                 |
| Find next                        | Command + G              | Ctrl + G                 |
| Find previous                    | Shift + Command + G      | Shift + Ctrl + G         |
| Show line numbers                | Shift + L                | Shift + L                |
| Render side-by-side              | Shift + R                | Shift + R                |

## Edit Mode Shortcuts

| Task               | Mac                 | Windows          |
| ------------------ | ------------------- | ---------------- |
| Go to command mode | Esc                 | Esc              |
| Select all cells   | Command + A         | Ctrl + A         |
| Undo               | Command + Z         | Ctrl + Z         |
| Redo               | Shift + Command + Z | Shift + Ctrl + Z |
| Go to cell start   | Command + Up        | Ctrl + Home      |
| Go to cell end     | Command + Down      | Ctrl + End       |
| Go one word left   | Command + Left      | Ctrl + Left      |
| Go one word right  | Command + Right     | Ctrl + Right     |

***

Modified at: May 11, 2026

Source: [/cloud/container-services/notebooks/develop-with-notebooks/](https://docs.singlestore.com/cloud/container-services/notebooks/develop-with-notebooks/)

(An index of the documentation is available at /llms.txt)
