-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: SQLAlchemy 2.0.0 creates incompatibility with Pandas read_sql (fails to execute) #51015
Comments
See #40686 |
Yep agree, can you post your example there? Closing here |
Seems like pinning I ran into this starting Saturday as an unpinned Here is a Docker-based repro: # test.py
import pandas as pd
pd.DataFrame([{"n": 11}]).to_sql("test", "sqlite:///test.db")
print(pd.read_sql_table("test", "sqlite:///test.db")) # Dockerfile
FROM python:3.9-slim
ARG SQLALCHEMY
RUN pip install pandas==1.5.3 sqlalchemy==$SQLALCHEMY
COPY test.py test.py
ENTRYPOINT [ "python", "test.py" ] # bash
docker build -t pd-sqla2-test --build-arg SQLALCHEMY=2.0.0 .
docker run --rm pd-sqla2-test # ❌ fails with sqlalchemy 2.0.0
# Traceback (most recent call last):
# File "//test.py", line 3, in <module>
# print(pd.read_sql_table('test', 'sqlite:///test.db'))
# File "/usr/local/lib/python3.9/site-packages/pandas/io/sql.py", line 286, in read_sql_table
# table = pandas_sql.read_table( # type: ignore[union-attr]
# File "/usr/local/lib/python3.9/site-packages/pandas/io/sql.py", line 1460, in read_table
# return table.read(
# File "/usr/local/lib/python3.9/site-packages/pandas/io/sql.py", line 1003, in read
# result = self.pd_sql.execute(sql_select)
# File "/usr/local/lib/python3.9/site-packages/pandas/io/sql.py", line 1405, in execute
# return self.connectable.execution_options().execute(*args, **kwargs)
# AttributeError: 'OptionEngine' object has no attribute 'execute'
docker build -t pd-sqla1-test --build-arg SQLALCHEMY=1.4.46 .
docker run --rm pd-sqla1-test # ✅ works with sqlalchemy 1.4.46
# index n
# 0 0 11
# 1 1 22 For some reason this manifested for me as a hang in a #40686 lists this as an "enhancement" dating back a couple years, but the "BUG" and description here feels more apt at this point, as |
The problem with using sqlalchemy <2.0 as the workaround is that those of us using oracle cannot use the new oracledb library in conjunction with |
using .connection() also works
|
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
With the newest release of SQLAlchemy (2.0, released on 26. Jan 23), the read_sql function fails with the following stacktrace:
Expected Behavior
Should return the table as it did moments ago before I ran the package update.
I.e. this works with sqlalchemy vs. 1.4.46 - installing that version is a working workaround!
Installed Versions
The text was updated successfully, but these errors were encountered: