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


10.5.19 MySQLCursor.lastrowid Property

Syntax:

id = cursor.lastrowid

This read-only property returns the value generated for anAUTO_INCREMENT column by the previousINSERT orUPDATE statement orNone when there is no such value available. For example, if you perform anINSERT into a table that contains anAUTO_INCREMENT column,lastrowid returns theAUTO_INCREMENT value for the new row. For an example, seeSection 5.3, “Inserting Data Using Connector/Python”.

Thelastrowid property is like themysql_insert_id() C API function; seemysql_insert_id().