-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
Observation
After upgrading to Pandas 2.2.0 calling read_sql_query with a SQLAlchemy query on an SQLAlchemy connection yielded "Query must be a string unless using sqlalchemy." without any indication why or what may have broken with the upgrade.
Analysis
Tracking the problem down it was found that pandasSQL_builder (code) calls sqlalchemy = import_optional_dependency("sqlalchemy", errors="ignore") to resolve the optional SQLAlchemy package (which was installed in my case)
Due to errors="ignore" the violation of the minimal required version for SQLAlchemy does not lead to a warn or raise (code) but just silently returns with None.
This in turn lets pandasSQL_builder silently default to SQLiteDatabase(con).
Feature Description
Proposed improvement
Do not ignore the minimal version violation in import_optional_dependency in this context but make it obvious. For example by introducing an additional "errors"-mode like import_optional_dependency("sqlalchemy", errors="raise-on-version-violation").
Alternative Solutions
./.
Additional Context
No response