Newsletter 5

Newsletter 5

To get updates like this one delivered to your inbox, subscribe to our newsletter.

Newsletter #5

Hi! 👋 You’re reading the fifth marimo newsletter.

We have two big announcements!

  1. marimo now has built-in support for SQL — query dataframes, CSVs, tables and more, and get results back as Python dataframes.
  2. We’ve standardized a third-party plugin API, based on anywidget. This makes it possible for you to make your own widgets and bring them into marimo!

We’re also starting a new tradition that we’re calling the spotlight: every newsletter, we’ll feature a project by a member of the marimo community. This month, our spotlight doubles as an announcement, since we’re featuring Trevor Manz’s work on anywidget and how it integrates with marimo.

Working on something related to machine learning, data science, or interactive computing that you’d like us to feature next month? Hit reply to let us know!

🦆🛢Announcing SQL support

For an interactive tutorial, run pip install --upgrade marimo && marimo tutorial sql at your command line.

SQL cells in marimo are easy-to-use and powerful at the same time, letting you query almost anything while mixing and matching Python and SQL.

How SQL works

Create a SQL cell. Create SQL cells with a single click:

create-sql-cell

Query anything. marimo uses duckdb to run queries, so it’s compatible with a large number of data sources. For example, here’s a SQL query on a Pandas dataframe (live example) — notice how much simpler it is than the equivalent Pandas code:

sql-query

And here’s how you might query CSVs or Parquet files, local or remote:

SELECT * FROM 's3://my-bucket/file.parquet';
-- or
SELECT * FROM read_csv('path/to/example.csv');
-- or
SELECT * FROM read_parquet('path/to/example.parquet');
-- or
SELECT * FROM 'https://datasets.marimo.app/cars.csv';

With a bit of set up and tuning, you can even query Postgres tables. And you can even run joins across heterogeneous data sources, such as a Postgres table and a dataframe, in a single query.

Get results back as Python. Query results are returned to you as Polars or Pandas dataframes, making it seamless for Pythonistas to get back in the flow.

Build dynamic queries. You can even interpolate Python values to dynamically build queries, using the familiar {} syntax from Python f-strings.

dynamic-query

SQL cells are reactive — interact with the dropdown and marimo will automatically re-run your query if autorun is enabled. Worried about expensive queries? Just disable autorun.

Bonus: SQL even works in WebAssembly notebooks

As a bonus, SQL queries even work entirely in the browser (no server required!). Check out our this tutorial notebook for an example.

🌟 Spotlight on anywidget, and announcing our plugin API

Learn more about our plugin API at our blog.

We’re excited to announce that we’re opening up a public plugin API for building custom UI elements, or “widgets”! In particular, we’ve standardized on anywidget as our third-party plugin API.

anywidget is a Python library that simplifies creating and publishing custom widgets that can be used in interactive programming environments, developed by Trevor Manz, PhD candidate at Harvard. We strongly believe in anywidget’s mission to provides a single interface for developing embeddable widgets inside other applications, such as Panel, Jupyter, and, of course, marimo.

The upshot of our anywidget adoption is two-fold:

  1. You can now use any anywidget in marimo with just one line of code, and it automatically becomes reactive. For example, check out Trevor’s demo at this link to see how marimo brings quak, an interactive data table implemented with anywidget, to life, with selections automatically updating a downstream plot.
  2. You can now develop custom widgets for marimo, limited only by your imagination; learn more at our docs and anywidget’s.

As an example, here’s how you’d use the anywidget quak in a marimo notebook:

import marimo as mo
 
import polars as pl
import quak
 
df = pl.read_parquet("https://github.com/uwdata/mosaic/raw/main/data/athletes.parquet")
widget = mo.ui.anywidget(quak.Widget(df))
widget

We’re passionate about developer experience, and it’s clear to us that Trevor is too — anywidget comes with excellent devX for creating widgets with either vanilla JavaScript or frameworks like React and Svelte.

We’re excited to see the innovations that you’ll bring to marimo with anywidget. Happy building!

-Akshay & Myles