Create custom marimo snippet library for connections, charts, and queries #75

Closed
opened 2026-03-21 20:57:01 +00:00 by kert · 0 comments
Owner

Problem

No custom snippets — users re-type boilerplate for connections, charts, and common queries.

Solution

Marimo supports snippets.custom_paths in config. Create a snippet library:

Directory: notebooks/snippets/

Connection snippets (connections.py):

  • duckdb-connect — DuckDB setup with q() helper
  • trino-connect — Trino with catalog from config
  • nessie-connect — Nessie REST client
  • polaris-connect — Polaris OAuth2 client
  • bib-connect — Bibliography store
  • zotero-connect — Zotero SQLite
  • s3-connect — S3/RustFS client

Chart snippets (charts.py):

  • altair-bar — Horizontal bar chart with Nature theme
  • altair-line — Time series line chart
  • altair-scatter — Scatter plot with size encoding
  • altair-pie — Donut chart
  • altair-heatmap — Heatmap with custom palette

Query snippets (queries.py):

  • schema-overview — List all schemas and table counts
  • table-profile — Row count, column types, null rates
  • patient-demographics — Standard demographic breakdown
  • encounter-summary — Encounter types and trends
  • claims-pmpm — Per-member-per-month financial summary

Data loading snippets (loading.py):

  • load-polars — Polars DataFrame from DuckDB query
  • load-pandas — Pandas DataFrame from DuckDB
  • load-iceberg — Read Iceberg table via catalog

Config update:

# notebooks/.marimo.toml
[snippets]
custom_paths = ["/home/kert/notebooks/snippets"]

Files

  • notebooks/snippets/*.py (new directory)
  • notebooks/.marimo.toml
  • notebooks/.marimo-config/marimo.toml
  • notebooks/Dockerfile (COPY snippets)
## Problem No custom snippets — users re-type boilerplate for connections, charts, and common queries. ## Solution Marimo supports `snippets.custom_paths` in config. Create a snippet library: ### Directory: `notebooks/snippets/` **Connection snippets (`connections.py`):** - `duckdb-connect` — DuckDB setup with `q()` helper - `trino-connect` — Trino with catalog from config - `nessie-connect` — Nessie REST client - `polaris-connect` — Polaris OAuth2 client - `bib-connect` — Bibliography store - `zotero-connect` — Zotero SQLite - `s3-connect` — S3/RustFS client **Chart snippets (`charts.py`):** - `altair-bar` — Horizontal bar chart with Nature theme - `altair-line` — Time series line chart - `altair-scatter` — Scatter plot with size encoding - `altair-pie` — Donut chart - `altair-heatmap` — Heatmap with custom palette **Query snippets (`queries.py`):** - `schema-overview` — List all schemas and table counts - `table-profile` — Row count, column types, null rates - `patient-demographics` — Standard demographic breakdown - `encounter-summary` — Encounter types and trends - `claims-pmpm` — Per-member-per-month financial summary **Data loading snippets (`loading.py`):** - `load-polars` — Polars DataFrame from DuckDB query - `load-pandas` — Pandas DataFrame from DuckDB - `load-iceberg` — Read Iceberg table via catalog ### Config update: ```toml # notebooks/.marimo.toml [snippets] custom_paths = ["/home/kert/notebooks/snippets"] ``` ## Files - `notebooks/snippets/*.py` (new directory) - `notebooks/.marimo.toml` - `notebooks/.marimo-config/marimo.toml` - `notebooks/Dockerfile` (COPY snippets)
kert added this to the P14: Notebook DX — connections, snippets, templates, S3 buckets milestone 2026-03-21 20:57:01 +00:00
kert added the docs label 2026-03-21 20:57:01 +00:00
kert closed this issue 2026-03-22 00:26:10 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: homelab/stack#75