pola-rs/polars · error

writing with 'sqlalchemy' engine currently requires pandas.

Error message

writing with 'sqlalchemy' engine currently requires pandas.

Install with: pip install pandas

What it means

Error "writing with 'sqlalchemy' engine currently requires pandas. Install with: pip install pandas" thrown in pola-rs/polars.

Source

Thrown at py-polars/src/polars/dataframe/frame.py:4686

                    raise ModuleUpgradeRequiredError(
                        # https://github.com/apache/arrow-adbc/issues/1000
                        # https://github.com/apache/arrow-adbc/issues/1109
                        msg
                    )
                else:
                    n_rows = cursor.adbc_ingest(
                        table_name=unpacked_table_name,
                        data=data,
                        mode=mode,
                        **(engine_options or {}),
                    )
                conn.commit()
            return n_rows

        elif engine == "sqlalchemy":
            if not _PANDAS_AVAILABLE:
                msg = "writing with 'sqlalchemy' engine currently requires pandas.\n\nInstall with: pip install pandas"
                raise ModuleNotFoundError(msg)
            elif (pd_version := parse_version(pd.__version__)) < (1, 5):
                msg = f"writing with 'sqlalchemy' engine requires pandas >= 1.5; found {pd.__version__!r}"
                raise ModuleUpgradeRequiredError(msg)

            import_optional(
                module_name="sqlalchemy",
                min_version=("2.0" if pd_version >= (2, 2) else "1.4"),
                min_err_prefix="pandas >= 2.2 requires",
            )
            # note: the catalog (database) should be a part of the connection string
            from sqlalchemy.engine import Connectable, create_engine
            from sqlalchemy.orm import Session

            # note: we can only dispose of engines that we create ourselves;
            # caller-supplied connectables remain the caller's responsibility
            engine_to_dispose: Engine | None = None
            sa_object: Connectable

View on GitHub (pinned to df599052da)

When it happens

Trigger: Thrown at py-polars/src/polars/dataframe/frame.py:4686 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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