Skip to content

Latest commit

 

History

History
 
 

sql

SQL 🛢️

These examples show how to use marimo's built-in support for SQL, which is powered by duckdb, a fast in-process analytical database.

  • querying_dataframes.py shows hows to query Pandas or Polars dataframes
  • paremetrizing_sql_queries.py shows hows to parametrize queries with Python values
  • read_csv.py shows hows to read CSV data into duckdb
  • read_json.py shows hows to read JSON data into duckdb
  • read_parquet.py shows hows to read parquet data into duckdb
  • connect_to_sqlite.py shows hows to connect to a SQLite database
  • connect_to_postgres.py shows hows to connect to a PostgreSQL database
  • connect_to_motherduck.py shows hows to connect to motherduck
  • histograms.py shows hows to plot histograms of a column's values
  • misc/ contains illustrative examples

Tip

For a broad overview of using SQL in marimo, run marimo tutorial sql at the command-line.

Consult the duckdb documentation for a comprehensive guide on duckdb.

Running examples

The requirements of each notebook are serialized in them as a top-level comment. Here are the steps to open an example notebook:

  1. Install marimo
  2. Install uv
  3. Open an example with marimo edit --sandbox <notebook.py>.

Tip

The --sandbox flag opens the notebook in an isolated virtual environment, automatically installing the notebook's dependencies 📦

You can also open notebooks without uv, with just marimo edit <notebook.py>; however, you'll need to install the requirements yourself.