SQLite - retrieving ID of last row SQLite - retrieving ID of last row sqlite sqlite

SQLite - retrieving ID of last row


The way we handle this is to start a transaction, perform the insert or update, execute a SELECT last_insert_rowid() (retrieving its results), and then commit the transaction.

This should be atomic due to the transacted nature and the fact that this operation returns the information for the current connection, not any other connection to the DB.