Skip to content

Commit 995f91c

Browse files
Merge pull request #7961 from jorisvandenbossche/sql-7826
BUG: fix checking of table name in read_sql (GH7826)
2 parents b8c36be + 080a0a7 commit 995f91c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

doc/source/v0.15.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ For full docs, see the :ref:`Categorical introduction <categorical>` and the
400400

401401

402402

403-
403+
- Bug in checking of table name in ``read_sql`` in certain cases (:issue:`7826`).
404404

405405

406406

pandas/io/sql.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,12 @@ def read_sql(sql, con, index_col=None, coerce_float=True, params=None,
420420
sql, index_col=index_col, params=params,
421421
coerce_float=coerce_float, parse_dates=parse_dates)
422422

423-
if pandas_sql.has_table(sql):
423+
try:
424+
_is_table_name = pandas_sql.has_table(sql)
425+
except:
426+
_is_table_name = False
427+
428+
if _is_table_name:
424429
pandas_sql.meta.reflect(only=[sql])
425430
return pandas_sql.read_table(
426431
sql, index_col=index_col, coerce_float=coerce_float,

0 commit comments

Comments
 (0)