pola-rs/polars · error · NotImplementedError
Currently no support for
Error message
Currently no support for {self.driver_name!r} connection {self.cursor!r} What it means
to_polars dispatches to a driver-specific fast path (arrow-native fetch methods, SQLAlchemy, DBAPI fetchall) based on the cursor's type; if the connected driver is not among the supported ones, it raises NotImplementedError naming the driver and cursor. The library has no ingestion strategy for that driver yet.
Solutions
- Use a mainstream driver (psycopg2, pyodbc, cx_Oracle/oracledb, mysqlclient, sqlite3) or SQLAlchemy, which polars supports
- Prefer pl.read_database_uri with engine="connectorx" or "adbc" for exotic databases — it bypasses DBAPI entirely
- Fetch rows yourself with cursor.fetchall() and build the frame via pl.DataFrame(rows, schema=..., orient="row")
- Check/upgrade py-polars version; driver support expands over time
Example fix
// before df = pl.read_database(query, exotic_conn) # NotImplementedError // after rows = exotic_conn.cursor().execute(query).fetchall() df = pl.DataFrame(rows, orient="row") // or df = pl.read_database_uri(query, "exotic://user:pw@host/db", engine="connectorx")
Defensive patterns
Strategy: fallback
Validate before calling
SUPPORTED = ("psycopg2","psycopg","pyodbc","mysqlclient","pymysql","sqlite3","oracledb","cx_Oracle")
if getattr(conn, "__driver_name__", type(conn).__module__.split('.')[0]) not in SUPPORTED:
# plan B: fetch rows manually or use connectorx/adbc via read_database_uri
... Type guard
def is_arrow_native_cursor(cur) -> bool:
return any(hasattr(cur, m) for m in ("fetch_arrow_table", "fetch_df", "fetchall", "fetchmany")) Try / catch
try:
df = pl.read_database(query, conn)
except NotImplementedError:
rows = conn.cursor().execute(query).fetchall()
df = pl.DataFrame(rows, orient="row") Prevention
- Prefer documented drivers or SQLAlchemy engines with read_database
- Use pl.read_database_uri(engine="connectorx"/"adbc") for databases without DBAPI support
- Pin and test driver versions in CI to catch API changes early
When it happens
Trigger: Using pl.read_database with an exotic/unsupported DBAPI driver (e.g. niche drivers or wrappers whose cursor lacks the fetch methods polars special-cases) so no fast path or fallback applies.
Common situations: New or uncommon database drivers; custom cursor wrappers; drivers installed in versions that changed their cursor API; connecting via an ODBC/JDBC bridge polars doesn't recognise.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- cannot infer dtype from
- cannot return a frame before executing a query
- Cannot set `iter_batches` for
- Cannot set `iter_batches` without also setting a non-zero…
- `collect_all_async` is not supported by
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/1292aa03cb70f96d.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/io/database/_executor.py:648
self._from_arrow, # init from arrow-native data (where support exists)
self._from_rows, # row-wise fallback (sqlalchemy, dbapi2, pyodbc, etc)
):
frame = frame_init(
batch_size=batch_size,
iter_batches=iter_batches,
schema_overrides=schema_overrides,
infer_schema_length=infer_schema_length,
)
if frame is not None:
if defer_cursor_close:
frame_cursor = CloseAfterFrameIter(frame, cursor=self.cursor)
frame = (df for df in frame_cursor)
return frame
msg = (
f"Currently no support for {self.driver_name!r} connection {self.cursor!r}"
)
raise NotImplementedError(msg)
View on GitHub (pinned to fe841f959e)