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
3 changes: 1 addition & 2 deletions doc/source/whatsnew/v1.1.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ including other versions of pandas.

Fixed regressions
~~~~~~~~~~~~~~~~~
-
-
- Fixed regression in :func:`read_sql_table` raising a ``sqlalchemy.exc.OperationalError`` when column names contained a percentage sign (:issue:`37517`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to 1.2 i think we could put this in.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it to 1.2 and as bug fix, since it's not a regression fix if I understood you correctly.


.. ---------------------------------------------------------------------------

Expand Down
4 changes: 1 addition & 3 deletions pandas/io/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,9 +1159,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 @@ -1118,6 +1118,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