From 080a0a7172ef0d59092e1f78a0c8d07b181047f5 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Fri, 8 Aug 2014 11:56:04 +0200 Subject: [PATCH] BUG: fix checking of table name in read_sql (GH7826) --- doc/source/v0.15.0.txt | 2 +- pandas/io/sql.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/source/v0.15.0.txt b/doc/source/v0.15.0.txt index ecfd7b5ada055..ac475d637f9cf 100644 --- a/doc/source/v0.15.0.txt +++ b/doc/source/v0.15.0.txt @@ -400,7 +400,7 @@ For full docs, see the :ref:`Categorical introduction ` and the - +- Bug in checking of table name in ``read_sql`` in certain cases (:issue:`7826`). diff --git a/pandas/io/sql.py b/pandas/io/sql.py index 914ade45adaa1..d9d20c3b8b835 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -420,7 +420,12 @@ def read_sql(sql, con, index_col=None, coerce_float=True, params=None, sql, index_col=index_col, params=params, coerce_float=coerce_float, parse_dates=parse_dates) - if pandas_sql.has_table(sql): + try: + _is_table_name = pandas_sql.has_table(sql) + except: + _is_table_name = False + + if _is_table_name: pandas_sql.meta.reflect(only=[sql]) return pandas_sql.read_table( sql, index_col=index_col, coerce_float=coerce_float,