A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "altair==5.5.0",
# "polars[pyarrow]==1.27.1",
# "marimo[sql]",
# "duckdb==1.2.2",
# "sqlglot[c]>=30.11.0; python_version < '3.15'",
# "sqlglot[c]>=30.23.0; python_version >= '3.15'",
# ]
# ///
import marimo
__generated_with = "0.19.7"
app = marimo.App(width="medium", sql_output="polars")
@app.cell
def _():
import marimo as mo
import altair as alt
return alt, mo
@app.cell
def _(mo):
digits = mo.ui.slider(label="Digits", start=100, stop=10000, step=200)
digits
return (digits,)
@app.cell
def _(digits, mo):
result = mo.sql(
f"""
CREATE TABLE random_data AS
SELECT i AS id, RANDOM() AS random_value,
FROM range({digits.value}) AS t(i);
SELECT * FROM random_data;
"""
)
return (result,)
@app.cell
def _(alt, result):
# Plot the data using polars and altair
result.plot.bar(x=alt.X("random_value").bin(), y="count()")
return
if __name__ == "__main__":
app.run()