Skip to content

Commit

Permalink
BUG: allow DBAPI2 object #45416 (#45496)
Browse files Browse the repository at this point in the history
  • Loading branch information
fangchenli authored Jan 20, 2022
1 parent 04f5721 commit 3418679
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 @@ -731,6 +731,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 @@ -743,10 +744,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 3418679

Please sign in to comment.