Skip to content

Commit

Permalink
Backport PR pandas-dev#45496: BUG: allow DBAPI2 object pandas-dev#45416
Browse files Browse the repository at this point in the history
  • Loading branch information
fangchenli authored and meeseeksmachine committed Jan 20, 2022
1 parent cefb74c commit 52fb784
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit 52fb784

Please sign in to comment.