|
2 | 2 |
|
3 | 3 | Marimo UI helpers for [Hotdata](https://hotdata.dev): run SQL from a notebook, browse catalog metadata, and render results as tables. |
4 | 4 |
|
| 5 | +## Features |
| 6 | + |
| 7 | +- **Workspace-aware setup** — build a `HotdataClient` from environment variables, or use `workspace_selector_from_env()` to choose a workspace interactively when no workspace is pinned. |
| 8 | +- **Connection health** — show a compact status callout with API, workspace, and optional sandbox context. |
| 9 | +- **Catalog browsing** — browse Hotdata connections, schemas, tables, and columns from Marimo UI controls. |
| 10 | +- **SQL editor widget** — run SQL against Hotdata, cache the latest successful result, and render results in downstream reactive cells. |
| 11 | +- **Native `mo.sql` engine** — register `HotdataMarimoEngine` so Marimo SQL cells can execute through a live `HotdataClient` with `engine=client`. |
| 12 | +- **Result display helpers** — render query results, recent results, and run history as notebook-friendly UI. |
| 13 | +- **Marimo UI aliases** — importing `hotdata_marimo` attaches helpers such as `mo.ui.hotdata_sql_editor` and `mo.ui.hotdata_table_browser` for discoverability. |
| 14 | + |
5 | 15 | ## Install |
6 | 16 |
|
7 | 17 | ```bash |
@@ -39,6 +49,28 @@ Importing `hotdata_marimo` registers discoverability aliases on Marimo’s UI na |
39 | 49 |
|
40 | 50 | Use `hm.connection_status(client)` (or `mo.ui.hotdata_connection_status(client)`) for a small API/workspace health callout. |
41 | 51 |
|
| 52 | +## Marimo SQL Cells |
| 53 | + |
| 54 | +Register the Hotdata SQL engine once during setup, then pass a `HotdataClient` to Marimo SQL cells: |
| 55 | + |
| 56 | +```python |
| 57 | +import hotdata_marimo as hm |
| 58 | + |
| 59 | +hm.register_hotdata_sql_engine() |
| 60 | +client = hm.from_env() |
| 61 | +``` |
| 62 | + |
| 63 | +```python |
| 64 | +_df = mo.sql( |
| 65 | + """ |
| 66 | + SELECT 1 AS example_value |
| 67 | + """, |
| 68 | + engine=client, |
| 69 | +) |
| 70 | +``` |
| 71 | + |
| 72 | +The engine also exposes Hotdata catalog metadata to Marimo's data-source UI. Hotdata connections are labeled **Hotdata** in the SQL connection picker. |
| 73 | + |
42 | 74 | ## Two-cell pattern |
43 | 75 |
|
44 | 76 | Keep the editor in one cell and consume `editor.result` in another. The editor caches the last successful run so downstream cells do not re-query the API on every refresh; click **Run on Hotdata** again after you change SQL. While a query is running, a Marimo status spinner is shown. |
|
0 commit comments