Question: I'm using SQLite's `last_insert_rowid()` to grab the last inserted row ID following a batch insert. Is there any risk of race conditions that could cause this value to not return the last id of the batch insert? For example, is it possible that in between the completion of the insert and the calling of `last_insert_rowid()` some other process may have written to the table again?

Answer: 
`last_insert_rowid()` returns information about the last insert done in this specific connection; it cannot return a value written by some other process.

To ensure that the returned value corresponds to the current state of the database, take advantage of SQLite's [ACID](http://en.wikipedia.org/wiki/ACID) guarantees (here: atomicity): wrap the batch inserts, the `last_insert_rowid()` call, and whatever you're doing with the ID inside a single transaction.

In any case, the return value of `last_insert_rowid()` changes only when some insert is done through this connection, so you should never access the same connection from multiple threads, or if you really want to do so, manually serialize entire transactions.
`last_insert_rowid()` is connection-dependent, so there is a risk when multiple threads are using the same connection, without SQLite switched to Serialized threading mode.