Retry SQLite3 operations when table is locked

Just like it says on the tin, if the table is locked or busy, we retry the operation.

Fixes #122