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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
docs: cleanup motherduck docs (#3260)
Myles Scolnick534978743c2c
diff --git a/docs/integrations/motherduck.md b/docs/integrations/motherduck.mdindex 3e734ebe70..6bf991001d 100644--- a/docs/integrations/motherduck.md+++ b/docs/integrations/motherduck.md@@ -32,23 +32,36 @@ conda install -c conda-forge marimo duckdb polarsTo connect to MotherDuck, import `duckdb` and `ATTACH` your MotherDuck database.+## Using MotherDuck++### 1. Connecting and Database Discovery++/// tab | SQL++```sql+ATTACH IF NOT EXISTS 'md:my_db'+```++///++/// tab | Python+```pythonimport duckdb-# Connect to MotherDuckduckdb.sql("ATTACH IF NOT EXISTS 'md:my_db'")```-You will be prompted to authenticate with MotherDuck when you run the above cell. This will open a browser window where you can log in and authorize marimo to access your MotherDuck database. In order to avoid being prompted each time you open a notebook, you can set the `motherduck_token` environment variable:+///++You will be prompted to authenticate with MotherDuck when you run the above cell. This will open a browser window where you can log in and authorize your marimo notebook to access your MotherDuck database. In order to avoid being prompted each time you open a notebook, you can set the `motherduck_token` environment variable:```bash-export motherduck_token="your_motherduck_token_here"+export motherduck_token="your_token"marimo edit```-You can obtain this token from your MotherDuck account settings.--Once you've authenticated, your MotherDuck tables get automatically discovered and you can browse them from the Datasources Panel.+Once connected, your MotherDuck tables are automatically discovered in the Datasources Panel:<div align="center"><figure>@@ -57,9 +70,9 @@ Once you've authenticated, your MotherDuck tables get automatically discovered a</figure></div>-## 2. Querying Your Tables+### 2. Writing SQL Queries-Once connected, you can query your MotherDuck tables using SQL. Here's an example of how to query a table and display the results using marimo:+You can query your MotherDuck tables using SQL cells in marimo. Here's an example of how to query a table and display the results using marimo:<div align="center"><figure>@@ -68,11 +81,11 @@ Once connected, you can query your MotherDuck tables using SQL. Here's an exampl</figure></div>-marimo's reactive execution model extends into SQL queries, so changes to your SQL will automatically trigger downstream computations for dependent cells.+marimo's reactive execution model extends into SQL queries, so changes to your SQL will automatically trigger downstream computations for dependent cells (or optionally mark cells as stale for expensive computations).<video controls width="100%" height="100%" align="center" src="/_static/motherduck/motherduck_reactivity.mp4"> </video>-## 3. Mixing SQL and Python+### 3. Mixing SQL and PythonMotherDuck allows you to seamlessly mix SQL queries with Python code, enabling powerful data manipulation and analysis. Here's an example:@@ -85,7 +98,7 @@ MotherDuck allows you to seamlessly mix SQL queries with Python code, enabling pThis example demonstrates how you can use SQL to query your data, then use Python and marimo to further analyze and visualize the results.-## Example+## Example NotebookFor a full example of using MotherDuck with marimo, check out our [MotherDuck example notebook](https://github.com/marimo-team/marimo/blob/main/examples/sql/connect_to_motherduck.py).