Skip to content

Commit c0b77e5

Browse files
erfannarimanmeeseeksmachine
authored andcommitted
Backport PR pandas-dev#37534: BUG: error raise when column contains percentage
1 parent 8d4b946 commit c0b77e5

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
@@ -1159,9 +1159,7 @@ def run_transaction(self):
11591159

11601160
def execute(self, *args, **kwargs):
11611161
"""Simple passthrough to SQLAlchemy connectable"""
1162-
return self.connectable.execution_options(no_parameters=True).execute(
1163-
*args, **kwargs
1164-
)
1162+
return self.connectable.execution_options().execute(*args, **kwargs)
11651163

11661164
def read_table(
11671165
self,

pandas/tests/io/test_sql.py

+9
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,15 @@ def test_query_by_select_obj(self):
11251125
all_names = set(iris_df["Name"])
11261126
assert all_names == {"Iris-setosa"}
11271127

1128+
def test_column_with_percentage(self):
1129+
# GH 37157
1130+
df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]})
1131+
df.to_sql("test_column_percentage", self.conn, index=False)
1132+
1133+
res = sql.read_sql_table("test_column_percentage", self.conn)
1134+
1135+
tm.assert_frame_equal(res, df)
1136+
11281137

11291138
class _EngineToConnMixin:
11301139
"""

0 commit comments

Comments
 (0)