Skip to content

BUG: error raise when column contains percentage #37534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 22, 2020
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ I/O
- Bumped minimum xarray version to 0.12.3 to avoid reference to the removed ``Panel`` class (:issue:`27101`)
- :meth:`DataFrame.to_csv` was re-opening file-like handles that also implement ``os.PathLike`` (:issue:`38125`)
- Bug in the conversion of a sliced ``pyarrow.Table`` with missing values to a DataFrame (:issue:`38525`)
- Bug in :func:`read_sql_table` raising a ``sqlalchemy.exc.OperationalError`` when column names contained a percentage sign (:issue:`37517`)

Period
^^^^^^
Expand Down
4 changes: 1 addition & 3 deletions pandas/io/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,9 +1237,7 @@ def run_transaction(self):

def execute(self, *args, **kwargs):
"""Simple passthrough to SQLAlchemy connectable"""
return self.connectable.execution_options(no_parameters=True).execute(
*args, **kwargs
)
return self.connectable.execution_options().execute(*args, **kwargs)

def read_table(
self,
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/io/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,15 @@ def test_query_by_select_obj(self):
all_names = set(iris_df["Name"])
assert all_names == {"Iris-setosa"}

def test_column_with_percentage(self):
# GH 37157
df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]})
df.to_sql("test_column_percentage", self.conn, index=False)

res = sql.read_sql_table("test_column_percentage", self.conn)

tm.assert_frame_equal(res, df)


class _EngineToConnMixin:
"""
Expand Down