MySQL Connector/Python Developer Guide / ... / Connector/Python API Reference / cursor.MySQLCursor Class / MySQLCursor.rowcount Property
Syntax:
count = cursor.rowcount This read-only property returns the number of rows returned forSELECT statements, or the number of rows affected by DML statements such asINSERT orUPDATE. For an example, seeSection 10.5.7, “MySQLCursor.execute() Method”.
For nonbuffered cursors, the row count cannot be known before the rows have been fetched. In this case, the number of rows is -1 immediately after query execution and is incremented as rows are fetched.
Therowcount property is like themysql_affected_rows() C API function; seemysql_affected_rows().