You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Marimo UI helpers for [Hotdata](https://hotdata.dev): run SQL from a notebook, browse catalog metadata, and render results as tables.
3
+
Marimo widgets for [Hotdata](https://hotdata.dev): run SQL, browse catalogs, load managed databases, and display results in notebooks.
4
4
5
-
## Features
5
+
Requires Python 3.10+, [Marimo](https://marimo.io/), and [hotdata-runtime](https://github.com/hotdata-dev/hotdata-runtime) (installed automatically).
6
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.
7
+
## Supported widgets
8
+
9
+
Importing `hotdata_marimo` registers `mo.ui.hotdata_*` aliases for discoverability.
10
+
11
+
| Widget | Function | Notes |
12
+
|--------|----------|-------|
13
+
| SQL editor |`hm.sql_editor(client)`| Returns `.ui` and `.result`|
| Workspace selector |`hm.workspace_selector_from_env()`| Pick workspace when `HOTDATA_WORKSPACE` is unset |
18
+
| Connection picker |`hm.connection_picker(client)`| Dropdown of workspace connections |
19
+
| Connection status |`hm.connection_status(client)`| API / workspace health callout |
20
+
| Connections panel |`hm.connections_panel(client)`| Status callout plus connection list |
21
+
| Query result |`hm.query_result(result)`| Render a `QueryResult` as a table |
22
+
| Recent results |`hm.recent_results(client)`| Browse past query results |
23
+
| Run history |`hm.run_history(client)`| Recent query runs |
24
+
25
+
Each widget also has a `mo.ui.hotdata_*` alias (e.g. `mo.ui.hotdata_sql_editor`). Native Marimo SQL cells are supported via `hm.register_hotdata_sql_engine()` and `mo.sql(..., engine=client)`.
14
26
15
27
## Install
16
28
17
29
```bash
18
-
uv pip install hotdata-marimo
19
-
# or: pip install hotdata-marimo
30
+
pip install hotdata-marimo
31
+
```
32
+
33
+
Set `HOTDATA_API_KEY`. Optionally set `HOTDATA_WORKSPACE`, `HOTDATA_API_URL`, or `HOTDATA_SANDBOX`.
34
+
35
+
## Connect
36
+
37
+
```python
38
+
import hotdata_marimo as hm
39
+
40
+
client = hm.from_env()
20
41
```
21
42
22
-
Requires Python 3.10+, **Marimo**, and [**hotdata-runtime**](https://github.com/hotdata-dev/hotdata-runtime) (Hotdata SDK + runtime/session semantics — pulled in automatically when you `pip install hotdata-marimo`).
43
+
If `HOTDATA_WORKSPACE` is unset, pick a workspace interactively:
44
+
45
+
```python
46
+
ws = hm.workspace_selector_from_env()
47
+
client = ws.client
48
+
```
23
49
24
-
## Environment
50
+
## SQL editor widget
25
51
26
-
| Variable | Required | Description |
27
-
|----------|----------|-------------|
28
-
|`HOTDATA_API_KEY`| Yes | API key for the Hotdata API |
29
-
|`HOTDATA_API_URL`| No | API base URL (default: `https://api.hotdata.dev`) |
30
-
|`HOTDATA_WORKSPACE`| No | Workspace id; if unset, the first active workspace is used |
31
-
|`HOTDATA_SANDBOX`| No | Sandbox session id, passed through to the SDK |
52
+
Run SQL in one cell; show results in the next. Marimo only renders what you **`return`**.
Importing `hotdata_marimo` registers discoverability aliases on Marimo’s UI namespace, so you can also use `mo.ui.hotdata_sql_editor`, `mo.ui.hotdata_table_browser`, `mo.ui.hotdata_query_result`, and `mo.ui.hotdata_connection_status`.
71
+
Click **Run on Hotdata** after changing SQL. The editor caches the last successful result so downstream cells do not re-query on every refresh.
49
72
50
-
Use `hm.connection_status(client)` (or `mo.ui.hotdata_connection_status(client)`) for a small API/workspace health callout.
73
+
## Native Marimo SQL cells
51
74
52
-
## Marimo SQL Cells
75
+
Register the Hotdata engine once, then pass `engine=client` to `mo.sql`. Hotdata appears as **Hotdata** in the SQL connection picker.
53
76
54
-
Register the Hotdata SQL engine once during setup, then pass a `HotdataClient` to Marimo SQL cells:
77
+
**Setup cell**
55
78
56
79
```python
80
+
import marimo as mo
57
81
import hotdata_marimo as hm
58
82
59
83
hm.register_hotdata_sql_engine()
60
84
client = hm.from_env()
61
85
```
62
86
87
+
**SQL cell**
88
+
63
89
```python
64
90
_df = mo.sql(
65
91
"""
@@ -69,46 +95,57 @@ _df = mo.sql(
69
95
)
70
96
```
71
97
72
-
The engine also exposes Hotdata catalog metadata to Marimo's data-source UI. Hotdata connections are labeled **Hotdata** in the SQL connection picker.
98
+

99
+
100
+
## Browse tables
101
+
102
+
```python
103
+
browser = hm.table_browser(client)
104
+
return browser.ui
105
+
```
106
+
107
+
Pick a connection, schema, and table to inspect columns. Use `browser.selected_table` in downstream cells.
73
108
74
-
## Two-cell pattern
109
+
## Managed databases
75
110
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.
111
+
Create a Hotdata-owned catalog and load a parquet file from the notebook:
77
112
78
-
Marimo only shows **what you `return` from a cell**. Calling `mo.vstack(...)` or `hm.query_result(...)` without returning it produces no visible output.
113
+
```python
114
+
panel = hm.databases_panel(client)
115
+
return panel
116
+
```
79
117
80
-
See `examples/demo.py` for a full runnable notebook flow.
118
+
Or use the lower-level writer API:
81
119
82
-
## Examples
120
+
```python
121
+
writer = hm.managed_database_writer(client)
122
+
return writer.ui
123
+
```
83
124
84
-
-`examples/demo.py` — tabbed explorer with workspace selection, connection health, recent results (selectable table), run history, and a native `mo.sql` cell.
125
+
## Other helpers
85
126
86
-
Run locally (single-user machine):
127
+
See [Supported widgets](#supported-widgets) for the full list. Quick examples:
87
128
88
-
```bash
89
-
uv run marimo edit examples/demo.py --no-token
129
+
```python
130
+
return hm.connection_status(client)
131
+
return hm.connections_panel(client)
132
+
return hm.recent_results(client).ui
133
+
return hm.run_history(client)
90
134
```
91
135
92
-
On a **shared or networked host**, omit `--no-token` and use the access token printed in the terminal URL. Without it, anyone who can reach the Marimo port can run queries against your Hotdata workspace.
136
+
## Demo notebook
93
137
94
-
## Layout
138
+
```bash
139
+
uv run marimo edit examples/demo.py --no-token
140
+
```
95
141
96
-
This repo is intentionally thin: **API client, env helpers, and result models** live in **hotdata-runtime**; **hotdata-marimo** only adds Marimo widgets (`sql_editor`, `table_browser`, `display` for tables/status/history, `workspace_selector`). Import `HotdataClient` / `QueryResult` / `from_env` from **`hotdata_marimo`** or directly from **`hotdata_runtime`**.
142
+
`examples/demo.py` combines workspace selection, catalog browsing, managed databases, query history, and a native `mo.sql` cell.
97
143
98
144
## Development
99
145
100
-
This package depends on [**hotdata-runtime**](https://github.com/hotdata-dev/hotdata-runtime) (PyPI name `hotdata-runtime`). Development uses **uv**; keep a sibling checkout at `../hotdata-runtime` so the lockfile resolves the runtime from disk (see `[tool.uv.sources]` in `pyproject.toml`).
101
-
102
146
```bash
103
147
uv sync --locked
104
148
uv run pytest
105
-
marimo edit examples/demo.py --no-token
106
149
```
107
150
108
-
To pin **hotdata-runtime** from Git instead of the sibling path, remove the `[tool.uv.sources]` block, set the dependency line as needed, and run `uv lock` again.
109
-
110
-
For a **publishable**`uv.lock` (CI that only clones this repo), remove `[tool.uv.sources]`, point `hotdata-runtime` at PyPI or `git+https://…`, then `uv lock`.
111
-
112
-
The **`[project] name`** in [hotdata-runtime](https://github.com/hotdata-dev/hotdata-runtime)`pyproject.toml` is **`hotdata-runtime`** and the import package is **`hotdata_runtime`**.
113
-
114
-
Use **`--no-token`** for local development so the editor does not redirect to `/auth/login` (session auth is easy to hit with a global Marimo config). For a public or shared machine, omit it and use the printed URL with an access token instead.
151
+
See [hotdata-runtime](https://github.com/hotdata-dev/hotdata-runtime) for the underlying API client.
0 commit comments