---
title: "Marimo"
description: "Marimo is an open-source reactive Python notebook, stored as plain .py files, with native SQL cells backed by DuckDB by default."
canonical: "https://motherduck.com/glossary/marimo/"
related:
  - title: "Marimo | MotherDuck Docs"
    url: "https://motherduck.com/docs/integrations/data-science-ai/marimo/"
  - title: "Marimo + MotherDuck Integration | DuckDB Analytics"
    url: "https://motherduck.com/ecosystem/marimo/"
  - title: "Claude Code + Dives = Any data UI"
    url: "https://motherduck.com/blog/claude-code-plus-dives-equals-any-data-ui/"
---

# 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.

<glossary-callout video="smarter-ai-workflows-with-hex-motherduck" />

## 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.

```python
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.