From 52fb78457b14ce7979d69d80fcea03b303597314 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Thu, 20 Jan 2022 12:21:24 -0600 Subject: [PATCH] Backport PR #45496: BUG: allow DBAPI2 object #45416 --- pandas/io/sql.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandas/io/sql.py b/pandas/io/sql.py index f7fdc47afa8d1..8694e7ff62118 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -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) @@ -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):