Repository navigation
feat(sql): add native ConnectorX SQL engine support - #12234
GiacomoSaccaggi wants to merge 3 commits into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
dfbfa81 to
3b2b776
Compare
Relates to marimo-team#10396. ConnectorX is a Rust-based SQL connector that reads query results directly into Arrow format, enabling zero-copy conversion to Polars. This PR adds it as a first-class SQL engine so users can pass a ConnectorXConnection URI directly to any marimo SQL cell without wrapping it in a SQLAlchemy engine. Key design decisions: - ConnectorXConnection wrapper class (not plain string matching) to avoid any risk of hijacking existing SQLAlchemy string variables - Always uses return_type='arrow' (requires connectorx>=0.4.6, which removed the deprecated 'arrow2' return type) - Zero-copy Arrow->Polars via pl.from_arrow(); pandas not imported when output is 'polars' or 'native' - QueryEngine only (no EngineCatalog): ConnectorX has no introspection API; Data Sources panel shows the connection but not schemas/tables - Credentials masked in repr, display names, and all exception messages Supported URI schemes: postgresql, mysql, sqlite, trino (+https/+http), redshift, bigquery, mssql, oracle, clickhouse. Co-authored-by: Elisa Tedde <79220600+elitedde@users.noreply.github.com>
Co-authored-by: Elisa Tedde <79220600+elitedde@users.noreply.github.com>
e393640 to
5a95848
Compare
|
I have read the CLA Document and I hereby sign the CLA |
1 similar comment
|
I have read the CLA Document and I hereby sign the CLA |
recheck |
There was a problem hiding this comment.
🟡 Changes recommended
The TLS example disables certificate verification while sending credentials, exposing users to man-in-the-middle attacks, and incomplete redaction can leak passwords and tokens.
6 open issues
Keep TLS certificate verification enabled in the example · New Include PyArrow in the installation command · New Mask credentials in URI query parameters · New Handle missing PyArrow before running queries · New Redact URL-decoded passwords from error messages · New Add ConnectorX to CI test dependencies · New
What changed in this PR
Adds ConnectorX as a SQL engine, letting notebooks reuse connection URIs without SQLAlchemy, addressing #10396.
Changes:
- Registers ConnectorX and adds Arrow-based query execution with configurable output formats.
- Adds dialect, credential-masking, and query execution tests.
- Documents installation, usage, supported databases, and limitations.
| File | Description |
|---|---|
tests/_sql/test_connectorx.py |
Tests connection handling and query outputs. |
marimo/_sql/get_engines.py |
Registers the engine for discovery. |
marimo/_sql/engines/connectorx.py |
Implements the connection wrapper and execution adapter. |
marimo/_dependencies/dependencies.py |
Registers the ConnectorX dependency. |
docs/guides/working_with_data/sql.md |
Documents ConnectorX setup and usage. |
Review effort: Balanced
- Require pyarrow explicitly before reading Arrow results - Redact both percent-encoded and URL-decoded password from errors - Remove verify=false from docs example; add TLS warning admonition - Add pyarrow to install command in docs - Add test for URL-encoded password redaction
|
recheck |


📝 Summary
Relates to #10396.
This PR adds ConnectorX as a first-class SQL engine so users can pass a
ConnectorXConnectionURI directly to any marimo SQL cell — without wrapping it in a SQLAlchemy engine first.Motivation
Users already in the Polars ecosystem often connect to databases via
polars.read_database_uri(query, cx_uri), which uses ConnectorX under the hood. When migrating to marimo, they had to rewrite those connections as SQLAlchemy engines to use SQL cells. This PR removes that friction: the same URI just works.The main value over the existing SQLAlchemy path:
psycopg2, notrino-python-clientpl.from_arrow()is zero-copy. Pandas is never imported when output ispolarsornativepolars.read_database_uri()can reuse the exact same URI stringUsage
Then use
connin any SQL cell via the engine dropdown ormo.sql(..., engine=conn).Explicitly out of scope
Files changed
marimo/_dependencies/dependencies.pyconnectorx>=0.4.6inDependencyManagermarimo/_sql/engines/connectorx.pyConnectorXConnectionwrapper +ConnectorXEnginemarimo/_sql/get_engines.pySUPPORTED_ENGINEStests/_sql/test_connectorx.pydocs/guides/working_with_data/sql.mdTest coverage
Tests cover: dialect detection (13 URI schemes), credential masking,
is_compatiblerejection of plain strings (SQLAlchemy non-regression), missing-dependency error, Trino URI pass-through with mockedcx.read_sqlassertingreturn_type='arrow'(never'arrow2'), end-to-end SQLite queries for all output formats (polars, lazy-polars, pandas, native, auto).👋 First time contributor introduction
I'm Giacomo, a big fan of what the marimo team is building and I want to contribute back with something that comes directly from my own work. I build analytical dashboards on top of Trino data warehouses using Polars, and I'm also a contributor to ConnectorX itself — I fixed Trino URL parameter forwarding (#928) and stopped connection URLs from being incorrectly form-encoded (#933), which is what made
trino+https://...?verify=falsereliable in connectorx>=0.4.6. When I tried to bring that stack into marimo I hit exactly the friction in #10396: I had working ConnectorX URIs for Trino and had to rewrite everything as SQLAlchemy just to use SQL cells. This PR is my attempt to close that gap.📋 Pre-Review Checklist
cx_connselected in the SQL cell engine dropdown with live query results✅ Merge Checklist
docs/guides/working_with_data/sql.md)tests/_sql/test_connectorx.py)