Documentation Home
MySQL Connector/Python Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 0.7Mb
PDF (A4) - 0.7Mb


10.5.12 MySQLCursor.nextset() Method

Syntax:

Press CTRL+C to copy
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.

Press CTRL+C to copy
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.