Skip to content

Commit 3418679

Browse files
authored
BUG: allow DBAPI2 object #45416 (#45496)
1 parent 04f5721 commit 3418679

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
@@ -731,6 +731,7 @@ def pandasSQL_builder(con, schema: str | None = None):
731731
provided parameters.
732732
"""
733733
import sqlite3
734+
import warnings
734735

735736
if isinstance(con, sqlite3.Connection) or con is None:
736737
return SQLiteDatabase(con)
@@ -743,10 +744,13 @@ def pandasSQL_builder(con, schema: str | None = None):
743744
if isinstance(con, sqlalchemy.engine.Connectable):
744745
return SQLDatabase(con, schema=schema)
745746

746-
raise ValueError(
747+
warnings.warn(
747748
"pandas only support SQLAlchemy connectable(engine/connection) or"
748749
"database string URI or sqlite3 DBAPI2 connection"
750+
"other DBAPI2 objects are not tested, please consider using SQLAlchemy",
751+
UserWarning,
749752
)
753+
return SQLiteDatabase(con)
750754

751755

752756
class SQLTable(PandasObject):

0 commit comments

Comments
 (0)