MySQL Connector/Python Developer Guide / ... / Connector/Python API Reference / cursor.MySQLCursor Class / MySQLCursor.nextset() Method
Syntax:
row = cursor.nextset() This method makes the cursor skip to the next available set, discarding any remaining rows from the current set. It returnsNone if there are no more sets or returnsTrue 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 setThis method was added in Connector/Python 9.2.0.