datamapper/do — Issue #24: Exposing busy_timeout to sqlite3 API
Author: atotic
Created: 2012-02-12 08:07:34+00:00
State: open

Using datamapper and do_sqlite3 with multiple programs writing to the same db is impossible. The writes often fail with BusyError. I can work around it by using a different db, or hacking datamapper source to sleep/retry writes.

sqlite3 db engine has a built in 'retry on busy' function that fixes this problem:
http://www.sqlite.org/c3ref/busy_timeout.html

do_sqlite3 does not expose this API. What do you think of using this in do_sqlite3?

There are several ways to do it:
- set 'retry on busy' on every sqlite3 connection opened. The only side effect would be that people that were getting BusyError before would get slowdown in performance instead.
- allow developers to set the flag in the URI using query arguments (sqlite3://dev.sqlite?busy_retry=200

PS: I would not use this setup in production, but it is useful for development. Love the simplicity of sqlite3 setup.