is a serial process. If your getting a race condition, it's between 2 or more
ing and database handles; this can be very dangerous - particularly when it comes to SQLite. Also, you incrementing a key also in that environment is also very risky. If you want to avoid collisions and not change your set up, you need to look at generating some kind of globally unique identifier or checksum of the data record you're adding. You need to let the esteemed monks know what you're doing.