Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

docs: SQL (#1867)

Akshay Agrawal2ddd464de887
diff --git a/README.md b/README.md
index a86d2cafc2..cc86d9aefe 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,7 @@ and deployable as apps.
- **reproducible**: no hidden state, deterministic execution
- **executable**: execute as a Python script, parametrized by CLI args
- **shareable**: deploy as an interactive web app, or run in the browser via WASM
+- **data-centric**: built-in SQL support and data sources panel
- **git-friendly**: stored as `.py` files
```python
@@ -51,9 +52,12 @@ memory, eliminating hidden state.
<img src="https://raw.githubusercontent.com/marimo-team/marimo/main/docs/_static/reactive.gif" width="700px" />
-**Deterministic execution order.** Notebooks are executed in a deterministic
-order, based on variable references instead of cells' positions on the page.
-Organize your notebooks to best fit the stories you'd like to tell.
+<a name="expensive-notebooks"></a>
+
+**Compatible with expensive notebooks.** marimo lets you configure the runtime
+to be lazy, marking affected cells as stale instead of automatically running
+them. This gives you guarantees on program state while preventing accidental
+execution of expensive cells.
**Synchronized UI elements.** Interact with UI elements like sliders,
dropdowns, and dataframe transformers, and the cells that use them are
@@ -64,16 +68,24 @@ automatically re-run with their latest values.
**Performant runtime.** marimo runs only those cells that need to be run by
statically analyzing your code.
-<a name="expensive-notebooks"></a>
+**Dynamic markdown and SQL.** Use markdown to tell dynamic stories that depend on
+Python data. Or build [SQL](https://docs.marimo.io/guides/sql.html) queries
+that depend on Python values and execute them against dataframes, databases,
+CSVs, Google Sheets, or anything else using our built-in SQL engine, which
+returns the result as a Python dataframe.
-**Compatible with expensive notebooks.** You can optionally disable expensive cells to
-prevent them from automatically running, or configure the runtime to be
-lazy and mark affected cells as stale instead of automatically running them.
+<img src="https://raw.githubusercontent.com/marimo-team/marimo/main/docs/_static/readme-sql-cell.png" width="700px" />
+
+Your notebooks are still pure Python, even if they use markdown or SQL.
+
+**Deterministic execution order.** Notebooks are executed in a deterministic
+order, based on variable references instead of cells' positions on the page.
+Organize your notebooks to best fit the stories you'd like to tell.
**Batteries-included.** marimo comes with GitHub Copilot, Ruff code
formatting, HTML export, fast code completion, a [VS Code
extension](https://marketplace.visualstudio.com/items?itemName=marimo-team.vscode-marimo),
-and many more quality-of-life features.
+an interactive dataframe viewer, and many more quality-of-life features.
## Quickstart
diff --git a/docs/_static/readme-sql-cell.png b/docs/_static/readme-sql-cell.png
new file mode 100644
index 0000000000..4f6744e5ae
Binary files /dev/null and b/docs/_static/readme-sql-cell.png differ
diff --git a/docs/guides/index.md b/docs/guides/index.md
index 474ebb4cf2..1fa1e88cde 100644
--- a/docs/guides/index.md
+++ b/docs/guides/index.md
@@ -8,6 +8,7 @@
overview
reactivity
interactivity
+ sql
runtime_configuration
coming_from_jupyter
outputs
@@ -15,7 +16,6 @@
hotkeys
dataframes
plotting
- sql
state
integrating_with_marimo/index
apps
@@ -36,6 +36,7 @@ These guides cover marimo's core concepts.
| {doc}`overview` | An overview of basic concepts |
| {doc}`reactivity` | How reactive execution works |
| {doc}`interactivity` | Using interactive UI elements |
+| {doc}`sql` | Use SQL to query dataframes, databases, CSVs, etc. |
| {doc}`coming_from_jupyter` | marimo for Jupyter users |
| {doc}`runtime_configuration` | Configure how and when cells are run |
| {doc}`outputs` | Markdown, plots, and other visual outputs |
diff --git a/docs/guides/overview.md b/docs/guides/overview.md
index cc461c95d5..9f755a4196 100644
--- a/docs/guides/overview.md
+++ b/docs/guides/overview.md
@@ -158,3 +158,28 @@ The marimo library also comes with elements for laying out outputs, including
[`mo.accordion`](#marimo.accordion), [`mo.ui.tabs`](#marimo.ui.tabs), [`mo.sidebar`](#marimo.sidebar),
[`mo.nav_menu`](#marimo.nav_menu), [`mo.ui.table`](#marimo.ui.table),
and [many more](https://docs.marimo.io/api/layouts/index.html).
+
+## SQL
+
+marimo has built-in support for SQL: you can query Python dataframes,
+databases, CSVs, Google Sheets, or anything else. After executing your query,
+marimo returns the result to you as a dataframe, making it seamless
+to go back and forth between SQL and Python.
+
+<div align="center">
+ <figure>
+ <img src="/_static/docs-sql-df.png"/>
+ <figcaption>Query a dataframe using SQL!</figcaption>
+ </figure>
+</div>
+
+To create a SQL cell, click on the SQL button that appears at the bottom of the
+cell array, or right click the create cell button next to a cell.
+
+To learn more, run the SQL tutorial:
+
+```bash
+marimo tutorial sql
+```
+
+or read the [SQL guide](/guides/sql.md).
diff --git a/docs/guides/sql.md b/docs/guides/sql.md
index 7ee9b5bbc8..e0b46cb1ed 100644
--- a/docs/guides/sql.md
+++ b/docs/guides/sql.md
@@ -63,3 +63,13 @@ SELECT * FROM read_parquet('path/to/example.parquet');
```
For a full list you can check out the [duckdb extensions](https://duckdb.org/docs/extensions/overview).
+
+## Interactive tutorial
+
+For an interactive tutorial, run
+
+```bash
+marimo tutorial sql
+```
+
+at your command-line.
diff --git a/docs/index.md b/docs/index.md
index 37888918de..458da0751d 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -4,9 +4,10 @@
**marimo** is a reactive notebook for Python that models notebooks as dataflow
graphs. Run a cell or interact with a UI element, and marimo automatically runs
-affected cells (or marks them as stale), keeping code and outputs consistent
-and preventing bugs before they happen. Every marimo notebook is stored as pure
-Python, executable as a script, and deployable as an app.
+affected cells (or [marks them as stale](/guides/runtime_configuration.md)),
+keeping code and outputs consistent and preventing bugs before they happen.
+Every marimo notebook is stored as pure Python, executable as a script, and
+deployable as an app.
```{admonition} Built from the ground up
:class: tip
@@ -38,10 +39,12 @@ reproducibility, maintainability, composability, and shareability.
**Highlights.**
-- **reactive**: run a cell and marimo automatically runs affected cells and updates their outputs
+- **reactive**: run a cell and marimo automatically runs dependent cells
- **interactive**: bind sliders, tables, plots, and more to Python — no callbacks required
-- **reproducible**: no hidden state, deterministic execution order — code with confidence in your notebook's correctness
-- **deployable**: executable as a script, deployable as an app
+- **reproducible**: no hidden state, deterministic execution order
+- **executable**: execute as a Python script, parametrized by CLI args
+- **shareable**: deploy as an interactive web app, or run in the browser via WASM
+- **data-centric**: built-in SQL support and data sources panel
- **developer-friendly**: git-friendly `.py` file format, GitHub Copilot, fast autocomplete, code formatting, and more
> ⚡ marimo notebooks run automatically with interactions and code changes