Today is a good day to code

SQLite3 Last Row Inserted ID Equal 0

Posted: December 31st, 1969 | Author: | Filed under: Uncategorized | 1 Comment »

SQLite3 Last Row Inserted ID Equal 0

Picture of IrvinWhen working with SQLite3, I had an issue recently where sqlite3_last_insert_rowid(database) was returning 0. This normally means that there have been no inserts performance against the database. In my case, I had just done an insert that came back as OK.

It turns out that the problem was that I had too many databases open at one time. In the interest of data partitioning for performance, I had created 6 databases. I guess the libsqlite3.dylib will not allow that many different databases to be open at one time. Things seem OK when I have 3 open. I will try to figure out how many databases can be open at one time and report back. Or if I find it in the SQLite documentation I will come back and edit this post to report it.


  • 88brad

    Wow, saved my life.  Thanks =P