Skip to content

Commit 36b3060

Browse files
committed
Improve sqlalchemy Error Message
1 parent 17e23db commit 36b3060

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,
@@ -898,7 +901,10 @@ def pandasSQL_builder(
898901
sqlalchemy = import_optional_dependency("sqlalchemy", errors="ignore")
899902

900903
if isinstance(con, str) and sqlalchemy is None:
901-
raise ImportError("Using URI string without sqlalchemy installed.")
904+
raise ImportError(
905+
f"Using URI string without version '{VERSIONS['sqlalchemy']}' or newer "
906+
"of 'sqlalchemy' installed."
907+
)
902908

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

0 commit comments

Comments
 (0)