Skip to content

Commit 81f8d5d

Browse files
authored
Raise on SQLAlchemy minimal version violation Issue #57178 (#62751)
1 parent 6583c1d commit 81f8d5d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pandas/io/sql.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@
3535
from pandas._config import using_string_dtype
3636

3737
from pandas._libs import lib
38-
from pandas.compat._optional import import_optional_dependency
38+
from pandas.compat._optional import (
39+
VERSIONS,
40+
import_optional_dependency,
41+
)
3942
from pandas.errors import (
4043
AbstractMethodError,
4144
DatabaseError,
@@ -902,7 +905,10 @@ def pandasSQL_builder(
902905
sqlalchemy = import_optional_dependency("sqlalchemy", errors="ignore")
903906

904907
if isinstance(con, str) and sqlalchemy is None:
905-
raise ImportError("Using URI string without sqlalchemy installed.")
908+
raise ImportError(
909+
f"Using URI string without version '{VERSIONS['sqlalchemy']}' or newer "
910+
"of 'sqlalchemy' installed."
911+
)
906912

907913
if sqlalchemy is not None and isinstance(con, (str, sqlalchemy.engine.Connectable)):
908914
return SQLDatabase(con, schema, need_transaction)

0 commit comments

Comments
 (0)