pola-rs/polars · error · NotImplementedError

Currently no support for {self.driver_name!r} connection {se

Error message

Currently no support for {self.driver_name!r} connection {self.cursor!r}

What it means

Raised by ConnectionExecutor.to_polars() when neither _from_arrow nor _from_rows can initialise a frame from the given cursor/result object. Polars recognises a fixed set of driver cursor types (arrow-native drivers, SQLAlchemy, DBAPI2, pyodbc, etc.); anything else falls through to this NotImplementedError naming the driver and cursor class.

Source

Thrown at py-polars/src/polars/io/database/_executor.py:622

            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 df599052da)

Solutions

  1. Pass a standard surface polars supports: a SQLAlchemy Engine/Connection, a DBAPI-compliant connection, or a pyodbc connection
  2. Use pl.read_database_uri() with the connectorx or adbc engine if a URI is available for that database
  3. Upgrade polars — support for additional drivers is added over time and the cursor class may simply be too new
  4. As a last resort, fetch rows with the driver's own API and construct pl.DataFrame(rows, schema=...) manually

Example fix

# before
df = pl.read_database(query, exotic_driver_session)  # unsupported cursor type

# after
df = pl.read_database_uri(query, "sqlite:///data.db", engine="adbc")
# or
df = pl.DataFrame(exotic_cursor.fetchall(), schema=pl.Schema({...}))
Defensive patterns

Strategy: try-catch

Validate before calling

SUPPORTED_MODULES = ("sqlalchemy", "pyodbc", "adbc")
module = type(connection).__module__.split(".", 1)[0]
if not module.startswith(SUPPORTED_MODULES):
    # fall back to manual fetch before calling read_database
    ...

Try / catch

try:
    df = pl.read_database(query, conn)
except NotImplementedError:
    rows = conn.cursor().execute(query).fetchall()  # driver-native fetch
    df = pl.DataFrame(rows, orient="row", schema_overrides=schema)

Prevention

When it happens

Trigger: Passing an exotic or custom cursor/connection object to pl.read_database() whose type is not in the supported driver registry; a newer/renamed cursor class from a driver version polars does not yet recognise; wrapping a cursor in a proxy object that hides its real class.

Common situations: Using a niche database driver or an in-house connection wrapper; running a bleeding-edge driver version that renamed its cursor classes; passing a turbodbc/duckdb lower-level object instead of the standard DBAPI surface.

Related errors


AI-assisted analysis of pola-rs/polars@df599052da (2026-08-16). Data as JSON: /api/errors/1292aa03cb70f96d. Report an issue: GitHub.