Documentation Home
MySQL Connector/Python Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 0.6Mb
PDF (A4) - 0.6Mb
EPUB - 136.4Kb
HTML Download (TGZ) - 85.5Kb
HTML Download (Zip) - 103.3Kb


10.5.13 MySQLCursor.lastrowid Property

Syntax:

id = cursor.lastrowid

This read-only property returns the value generated for an AUTO_INCREMENT column by the previous INSERT or UPDATE statement or None when there is no such value available. For example, if you perform an INSERT into a table that contains an AUTO_INCREMENT column, lastrowid returns the AUTO_INCREMENT value for the new row. For an example, see Section 5.3, “Inserting Data Using Connector/Python”.

The lastrowid property is like the mysql_insert_id() C API function; see mysql_insert_id().


User Comments
Sign Up Login You must be logged in to post a comment.