← Back to Glossary

Marimo

Marimo is an open-source reactive Python notebook, stored as plain .py files, with native SQL cells backed by DuckDB by default.

Overview

Marimo is an open-source notebook for Python, built as an alternative to Jupyter that fixes some of its well-known pain points: hidden state from out-of-order cell execution, notebooks that don't diff or version well in Git, and a JSON file format that's awkward to review in a pull request. A marimo notebook is a single .py file, and it's reactive — when you change a cell, every downstream cell that depends on it automatically re-runs, so the notebook state can never silently drift out of sync with its code.

Native SQL cells

Marimo has first-class SQL cells that don't require magics or separate extensions. By default, a SQL cell runs against an in-memory DuckDB instance; write a SQL cell and marimo assumes it's DuckDB unless you configure a different backend (Postgres, MySQL, SQLite, and others are also supported through standard connectors). Under the hood, a SQL cell compiles to a call to mo.sql(), keeping the notebook file pure Python even though the editor renders it as a SQL editing experience.

Copy code

import marimo as mo df = mo.sql( f""" select category, sum(order_total) as revenue from orders group by category order by revenue desc """ )

The query result comes back as a dataframe (Polars if installed, otherwise pandas) that other Python cells can reference directly, and because SQL cells are just Python f-strings, queries can be parameterized with Python variables or UI element values, with the whole chain re-executing reactively when an input changes.

Marimo and MotherDuck

Because marimo's SQL engine is DuckDB itself, connecting to MotherDuck is a matter of using DuckDB's own MotherDuck attachment (a connection string with a service token) inside a marimo SQL cell, giving a notebook access to cloud-hosted DuckDB data with the same reactive, git-friendly workflow used for local data.

Related terms

FAQS

Marimo notebooks are reactive (changing a cell automatically re-runs its dependents), stored as plain, git-diffable .py files, and avoid the hidden state issues that come from Jupyter's out-of-order cell execution.

No. Marimo SQL cells run against an embedded DuckDB instance by default, so SQL cells work out of the box with no external database setup.

Yes, since marimo's SQL cells are backed by DuckDB, they can attach to a MotherDuck database using DuckDB's standard MotherDuck connection string and token.