-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Version 0.24.0 breaks read_sql compatibility with read_sql_query #24988
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
Comments
Can you step through the traceback and check where things break? It may be difficult for someone other than yourself to debug. |
@TomAugspurger I'll see what I can do. It will likely be a few days or more before I can delve deeper into this problem. |
Hello, Not sure if this will help or not but I am having the same issue. Everything was working flawlessly until I updated to 0.24.0. The error is below:
|
@fordmustang111 that looks like a different error. It seems like your install of pandas didn't go correctly. Can you reproduce in a new environment? Do you have a module named |
On the original issue, from looking at that error traceback and at the diff of the sql code between 0.23.4 and 0.24.0, I assume it is related to this change: https://github.com/pandas-dev/pandas/pull/23004/files#diff-b41f9fd042c423682f8e4c4d808dbe64R385 pymysql seems to be raising an InternalError, while we are only catching ImportError and AttributeError @Shellcat-Zero Thanks for the report! It should be an easy fix we can include in 0.24.1, main question is if we can also test it (I think we should be able to as we have pymysql tests) |
@Shellcat-Zero we're releasing 0.24.1 soonish (as early as tomorrow perhaps), so if you're able to construct a test quickly that'd be great. |
I bumped into this today. Python 3.7.0 Sample query: SELECT TOP 1 * FROM oe_hdr I called it in Python like this: engine = sqlalchemy.create_engine( $(my-connection-string) )
query = sqlalchemy.text("SELECT TOP 1 * FROM oe_hdr")
df = pandas.read_sql(query, engine) The problem I determined is that SELECT [INFORMATION_SCHEMA].[COLUMNS].[TABLE_SCHEMA],
[INFORMATION_SCHEMA].[COLUMNS].[TABLE_NAME],
[INFORMATION_SCHEMA].[COLUMNS].[COLUMN_NAME],
[INFORMATION_SCHEMA].[COLUMNS].[IS_NULLABLE],
[INFORMATION_SCHEMA].[COLUMNS].[DATA_TYPE],
[INFORMATION_SCHEMA].[COLUMNS].[ORDINAL_POSITION],
[INFORMATION_SCHEMA].[COLUMNS].[CHARACTER_MAXIMUM_LENGTH],
[INFORMATION_SCHEMA].[COLUMNS].[NUMERIC_PRECISION],
[INFORMATION_SCHEMA].[COLUMNS].[NUMERIC_SCALE],
[INFORMATION_SCHEMA].[COLUMNS].[COLUMN_DEFAULT],
[INFORMATION_SCHEMA].[COLUMNS].[COLLATION_NAME]
FROM
[INFORMATION_SCHEMA].[COLUMNS]
WHERE
[INFORMATION_SCHEMA].[COLUMNS].[TABLE_NAME] = SELECT TOP 1 FROM oe_hdr Notice that it includes the entire contents of my query as the |
@TomAugspurger When you say "construct a test", is that something different from what I provided in my initial report? If not, I most definitely have tests ready to run for you. |
A unittest similar to the others in pandas/tests/io/test_sql.py that reproduces your error, and is fixed by @jorisvandenbossche's suggestion in |
I did a quick try to create a test case that is failing with current master, but didn't succeed (https://github.com/pandas-dev/pandas/compare/master...jorisvandenbossche:read-sql-regression?expand=1 is still green on travis, don't have mysql locally) So I would propose to at least already fix the regression without a test? |
I opened #25024 with just the fix. @Shellcat-Zero @susodapop could you try if the fix in #25024 resolved the problem? (it's a 1-line change that you could edit in the installed pandas source, not ideal but should work for giving feedback)
Something like your initial report is fine, but, the main problem is that we need to get a failing test (without the fix) on Travis CI. That's what I tried in https://github.com/pandas-dev/pandas/compare/master...jorisvandenbossche:read-sql-regression?expand=1 but without luck. So there seems to be something different about the query you are doing. |
@Shellcat-Zero @susodapop would any body be able to confirm the fix? That would be very welcome! (I can't reproduce it locally) |
Hi @jorisvandenbossche -- I have confirmed that this fixes the problem on my end. I updated my local version of Pandas with the single change and now |
Thanks for confirming!
|
The following read_sql_query() works:
The same statements now fail in read_sql():
Problem description
Reverting to Pandas version 0.23.4 fixes the issue.
Output of
pd.show_versions()
[paste the output of
pd.show_versions()
here below this line]INSTALLED VERSIONS
commit: None
python: 3.6.5.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-1021-aws
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: C.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.24.0
pytest: None
pip: 19.0.1
setuptools: 39.2.0
Cython: None
numpy: 1.16.0
scipy: None
pyarrow: None
xarray: None
IPython: 7.2.0
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.9
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: None
html5lib: None
sqlalchemy: 1.2.17
pymysql: 0.9.3
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
The text was updated successfully, but these errors were encountered: