Skip to content

Commit af3ae05

Browse files
author
John Bodley
committed
1 parent 62fda2e commit af3ae05

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

doc/source/whatsnew/v1.1.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ I/O
790790
- Bug in :meth:`~DataFrame.read_feather` was raising an `ArrowIOError` when reading an s3 or http file path (:issue:`29055`)
791791
- Bug in :meth:`read_parquet` was raising a ``FileNotFoundError`` when passed an s3 directory path. (:issue:`26388`)
792792
- Bug in :meth:`~DataFrame.to_parquet` was throwing an ``AttributeError`` when writing a partitioned parquet file to s3 (:issue:`27596`)
793+
- Bug in :meth:`~SQLDatabase.execute` was raising a ``ProgrammingError`` for some DB-API drivers when the SQL statement contained the `%` character and no parameters were present (:issue:`34211`)
793794

794795
Plotting
795796
^^^^^^^^

pandas/io/sql.py

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

10801080
def execute(self, *args, **kwargs):
10811081
"""Simple passthrough to SQLAlchemy connectable"""
1082-
return self.connectable.execute(*args, **kwargs)
1082+
return self.connectable.execution_options(no_parameters=True).execute(
1083+
*args, **kwargs
1084+
)
10831085

10841086
def read_table(
10851087
self,

pandas/tests/io/test_sql.py

+10
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@
194194
"Name"=%(name)s AND "SepalLength"=%(length)s
195195
""",
196196
},
197+
"read_no_parameters_with_percent": {
198+
"sqlite": "SELECT * FROM iris WHERE Name LIKE '%'",
199+
"mysql": "SELECT * FROM iris WHERE `Name` LIKE '%'",
200+
"postgresql": "SELECT * FROM iris WHERE \"Name\" LIKE '%'",
201+
},
197202
"create_view": {
198203
"sqlite": """
199204
CREATE VIEW iris_view AS
@@ -424,6 +429,11 @@ def _read_sql_iris_named_parameter(self):
424429
iris_frame = self.pandasSQL.read_query(query, params=params)
425430
self._check_iris_loaded_frame(iris_frame)
426431

432+
def _read_sql_iris_no_parameter_with_percent(self):
433+
query = SQL_STRINGS["read_no_parameters_with_percent"][self.flavor]
434+
iris_frame = self.pandasSQL.read_query(query, params=None)
435+
self._check_iris_loaded_frame(iris_frame)
436+
427437
def _to_sql(self, method=None):
428438
self.drop_table("test_frame1")
429439

0 commit comments

Comments
 (0)