Skip to content

Commit 461ce9a

Browse files
authored
BUG: error raise when column contains percentage (#37534)
1 parent 0519914 commit 461ce9a

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

doc/source/whatsnew/v1.2.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ I/O
748748
- Bumped minimum xarray version to 0.12.3 to avoid reference to the removed ``Panel`` class (:issue:`27101`)
749749
- :meth:`DataFrame.to_csv` was re-opening file-like handles that also implement ``os.PathLike`` (:issue:`38125`)
750750
- Bug in the conversion of a sliced ``pyarrow.Table`` with missing values to a DataFrame (:issue:`38525`)
751+
- Bug in :func:`read_sql_table` raising a ``sqlalchemy.exc.OperationalError`` when column names contained a percentage sign (:issue:`37517`)
751752

752753
Period
753754
^^^^^^

pandas/io/sql.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1237,9 +1237,7 @@ def run_transaction(self):
12371237

12381238
def execute(self, *args, **kwargs):
12391239
"""Simple passthrough to SQLAlchemy connectable"""
1240-
return self.connectable.execution_options(no_parameters=True).execute(
1241-
*args, **kwargs
1242-
)
1240+
return self.connectable.execution_options().execute(*args, **kwargs)
12431241

12441242
def read_table(
12451243
self,

pandas/tests/io/test_sql.py

+9
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,15 @@ def test_query_by_select_obj(self):
12051205
all_names = set(iris_df["Name"])
12061206
assert all_names == {"Iris-setosa"}
12071207

1208+
def test_column_with_percentage(self):
1209+
# GH 37157
1210+
df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]})
1211+
df.to_sql("test_column_percentage", self.conn, index=False)
1212+
1213+
res = sql.read_sql_table("test_column_percentage", self.conn)
1214+
1215+
tm.assert_frame_equal(res, df)
1216+
12081217

12091218
class _EngineToConnMixin:
12101219
"""

0 commit comments

Comments
 (0)