Skip to content

Commit 52fb784

Browse files
fangchenlimeeseeksmachine
authored andcommitted
Backport PR pandas-dev#45496: BUG: allow DBAPI2 object pandas-dev#45416
1 parent cefb74c commit 52fb784

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pandas/io/sql.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ def pandasSQL_builder(con, schema: str | None = None):
742742
provided parameters.
743743
"""
744744
import sqlite3
745+
import warnings
745746

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

757-
raise ValueError(
758+
warnings.warn(
758759
"pandas only support SQLAlchemy connectable(engine/connection) or"
759760
"database string URI or sqlite3 DBAPI2 connection"
761+
"other DBAPI2 objects are not tested, please consider using SQLAlchemy",
762+
UserWarning,
760763
)
764+
return SQLiteDatabase(con)
761765

762766

763767
class SQLTable(PandasObject):

0 commit comments

Comments
 (0)