You can use the busy method.
Open the database:
sqlite3 $dbName $dbFilePath -readonly $readonly
Assign the procedure to run if busy:
$dbName busy $dbBusyProc
Our typical wait/busy proc looks like this
proc crmcSmatIndexDb::openWait { a } {
variable nsDbName
set waitMsec 2000
# will only email if attempt number (a) is greater than zero – added 09/22/2011 – jld
# first attempt is zero and increments from there – so, attempt 2 (a=1) will be
# the first to be emailed
crmcSqliteUtils::log $nsDbName “Attempt [expr $a + 1] – Database $nsDbName is locked – waiting $waitMsec milliseconds” $a
after $waitMsec
return 0
}
This will wait for two seconds (2000 ms) and then return – and the open will try again – continuously until the DB is available.
If you want to bail on the open after so many unsuccessful attempts, you can check if $a > 10, for example, then return a “1” instead of “0”.
… more detail at http://www.sqlite.org/tclsqlite.html
Jeff Dinsmore
Chesapeake Regional Healthcare