From ea013a254847fbc5551e3ec91a468370c7118589 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 31 Jan 2019 22:24:57 +0100 Subject: [PATCH] REGR: fix read_sql delegation for queries on MySQL/pymysql (#25024) --- doc/source/whatsnew/v0.24.1.rst | 1 + pandas/io/sql.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.24.1.rst b/doc/source/whatsnew/v0.24.1.rst index 521319c55a503..222963a7ff71a 100644 --- a/doc/source/whatsnew/v0.24.1.rst +++ b/doc/source/whatsnew/v0.24.1.rst @@ -22,6 +22,7 @@ Fixed Regressions - Bug in :meth:`DataFrame.itertuples` with ``records`` orient raising an ``AttributeError`` when the ``DataFrame`` contained more than 255 columns (:issue:`24939`) - Bug in :meth:`DataFrame.itertuples` orient converting integer column names to strings prepended with an underscore (:issue:`24940`) +- Fixed regression in :func:`read_sql` when passing certain queries with MySQL/pymysql (:issue:`24988`). - Fixed regression in :class:`Index.intersection` incorrectly sorting the values by default (:issue:`24959`). - Fixed regression in :func:`merge` when merging an empty ``DataFrame`` with multiple timezone-aware columns on one of the timezone-aware columns (:issue:`25014`). diff --git a/pandas/io/sql.py b/pandas/io/sql.py index 5d1163b3e0024..aaface5415384 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -381,7 +381,8 @@ def read_sql(sql, con, index_col=None, coerce_float=True, params=None, try: _is_table_name = pandas_sql.has_table(sql) - except (ImportError, AttributeError): + except Exception: + # using generic exception to catch errors from sql drivers (GH24988) _is_table_name = False if _is_table_name: