 <p>ok, looks like sqlite either doesn't have what I need, or I am missing it. Here's what I came up with:</p> <ul> <li><p>declare zorder as integer primary key autoincrement, zuid integer in orders table</p> <p>this means every new row gets an ascending number, starting with 1</p></li> <li><p>generate a random number:</p> <p>rnd = int(random.random() * 1000000) # unseeded python uses system time</p></li> <li><p>create new order (just the SQL for simplicity):</p> <p>'INSERT INTO orders (zuid) VALUES ('+str(rnd)+')'</p></li> <li><p>find that exact order number using the random number:</p> <p>'SELECT zorder FROM orders WHERE zuid = '+str(rnd)</p></li> <li><p>pack away that number as the new order number (newordernum)</p></li> <li><p>clobber the random number to reduce collision risks</p> <p>'UPDATE orders SET zuid = 0 WHERE zorder = '+str(newordernum)</p></li> </ul> <p>...and now I have a unique new order, I know what the correct order number is, the risk of a read collision is reduced to negligible, and I can prepare that order without concern that I'm trampling on another newly created order.</p> <p>Just goes to show you why DB authors implement sequences, lol.</p>