MySQL Connector/Python Release Notes
Syntax:
row = cursor.nextset()
This method makes the cursor skip to the next available set,
discarding any remaining rows from the current set. It returns
None
if there are no more sets or returns
True
and subsequent calls to the
cursor.fetch*() methods returns rows from the next result set.
This method can be used as part of the multi statement execution workflow.
sql_operation = '''
SET @a=1, @b='2025-01-01';
SELECT @a, LENGTH('hello'), @b;
SELECT @@version;
'''
with cnx.cursor() as cur:
cur.execute(sql_operation)
result_set = cur.fetchall()
# do something with result set
...
while cur.nextset():
result_set = cur.fetchall()
# do something with result set
This method was added in Connector/Python 9.2.0.