Be warned. I think that you should be careful with the db.transaction() because as far as I've been playing with it, it's broken. It doesn't provide any transaction isolation by default. It's better to use direct database transactions for isolation.
I'm so glad that I've seen these fails so many times, that I'm always writing test code to check out issues like these. And not blindly trusting bogus claims.
This while using Python 3.4 and SQLite3. If you want isolation to work, it's better to use db.execute_sql('begin;') because it does work and creates required locks, even if those are deferred in this case aka, optimistic concurrency control.