Skip to content

Commit 90fb325

Browse files
committed
WL#16285 BUG#36126909 BUG#35810050: Remake Multi Statement Execution
With this work log, the single and multi statement execution workflow is unified, as now there is no need to use the option `multi` to run a multi statement via `cursor.execute()`. Additionally, the workflow for traversing result sets generated from a multi statement execution is remade. Change-Id: I38a415f1f9f1b6f45ddd2c4ec81b1e03e6ba6f1e
1 parent ac1af72 commit 90fb325

30 files changed

+50190
-703
lines changed

CHANGES.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ Copyright (c) 2009, 2024, Oracle and/or its affiliates.
88
Full release notes:
99
http://dev.mysql.com/doc/relnotes/connector-python/en/
1010

11+
v9.2.0
12+
======
13+
14+
- WL16285: Remake Multi Statement Execution
15+
- BUG#36126909: "Unread result found" exception/bad MySQLCursor.statement when query text contains code comments
16+
- BUG#35810050: Executing multiple statements fails when importing Sakila
17+
1118
v9.1.0
1219
======
1320

mysql-connector-python/examples/multi_resultsets.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,25 @@ def main(config):
6767
"SELECT name FROM names",
6868
]
6969

70-
# Note 'multi=True' when calling cursor.execute()
71-
for result in cursor.execute(" ; ".join(stmts), multi=True):
72-
if result.with_rows:
73-
if result.statement == stmts[3]:
70+
cursor.execute(";".join(stmts), map_results=True)
71+
while True:
72+
if cursor.with_rows:
73+
if cursor.statement == stmts[3]:
7474
output.append(
75-
"Names in table: " + " ".join([name[0] for name in result])
75+
"Names in table: " + " ".join([name[0] for name in cursor])
7676
)
7777
else:
78-
output.append("Number of rows: {0}".format(result.fetchone()[0]))
78+
output.append("Number of rows: {0}".format(cursor.fetchone()[0]))
7979
else:
8080
output.append(
8181
"Inserted {0} row{1}".format(
82-
result.rowcount, "s" if result.rowcount > 1 else ""
82+
cursor.rowcount, "s" if cursor.rowcount > 1 else ""
8383
)
8484
)
8585

86+
if cursor.nextset() is None:
87+
break
88+
8689
cursor.execute(stmt_drop)
8790

8891
cursor.close()

0 commit comments

Comments
 (0)