Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ target/

# Jupyter Notebook
.ipynb_checkpoints
__marimo__/

# IPython
profile_default/
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ con.disconnect()
`database` means schema. Queries run remotely; results are buffered in memory.
Writes use the SDK directly. See the [runnable example](examples/ibis_queries.py).

### marimo

Use the Ibis connection with `mo.sql(query, engine=con)`. Try the
[notebook](examples/marimo_notebook.py) with `ALTERTABLE_USERNAME` and
`ALTERTABLE_PASSWORD` set:

```bash
pip install -e '.[ibis]' marimo
marimo edit examples/marimo_notebook.py
```

Use marimo's Datasources panel to add SQL cells for your own tables.

## Usage

### Initialization
Expand Down
49 changes: 49 additions & 0 deletions examples/marimo_notebook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import marimo

__generated_with = "0.25.1"
app = marimo.App(width="medium", sql_output="pandas")


@app.cell
def _():
import ibis
import marimo as mo

return ibis, mo


@app.cell
def _(ibis):
connection = ibis.altertable.connect()
return (connection,)


@app.cell
def _(mo):
minimum = mo.ui.slider(
0, 40, value=10, label="Minimum customer total", debounce=True, show_value=True
)
minimum
return (minimum,)


@app.cell
def _(connection, minimum, mo):
totals = mo.sql(
f"""
WITH orders(customer, amount) AS (
VALUES ('alice', 10), ('alice', 20), ('bob', 5)
)
SELECT customer, sum(amount) AS total
FROM orders
GROUP BY customer
HAVING sum(amount) >= {minimum.value}
ORDER BY customer
""",
engine=connection,
)
return (totals,)


if __name__ == "__main__":
app.run()
Loading