Skip to content

Backport PR #45496 on branch 1.4.x (BUG: allow DBAPI2 object #45416) #45502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pandas/io/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ def pandasSQL_builder(con, schema: str | None = None):
provided parameters.
"""
import sqlite3
import warnings

if isinstance(con, sqlite3.Connection) or con is None:
return SQLiteDatabase(con)
Expand All @@ -754,10 +755,13 @@ def pandasSQL_builder(con, schema: str | None = None):
if isinstance(con, sqlalchemy.engine.Connectable):
return SQLDatabase(con, schema=schema)

raise ValueError(
warnings.warn(
"pandas only support SQLAlchemy connectable(engine/connection) or"
"database string URI or sqlite3 DBAPI2 connection"
"other DBAPI2 objects are not tested, please consider using SQLAlchemy",
UserWarning,
)
return SQLiteDatabase(con)


class SQLTable(PandasObject):
Expand Down