Locking with SQLite
May 12, 2009 21:12:59 GMT -5
Post by Carl Gundel - admin on May 12, 2009 21:12:59 GMT -5
Okay I have a system working which allows for locking a SQLite database in order to prevent the database is locked errors. The idea is that applications which use a SQLite database can optionally lock that database using a semaphore.
sqliteconnect #db, "mydata.db", lock
This causes a lock to be registered for the instance of the program that invokes it, and on mydata.db. If another program also connects to that database using the lock option it will sit and wait until the first program unlocks it by calling disconnect().
If any program attempts to connect to a database that is has already a connection to, a runtime error will occur and also the connections and locks for that program will be released.
To use this mechanism effectively your Run BASIC program should always connect to a database only when it is about to read or write to it and then disconnect as soon as it is done. It won't work to have a connection across web pages or in between user actions, which wouldn't be recommended in any case even if you're using Oracle or some other database server.
This option may be made available for other database types as they become available.
-Carl
sqliteconnect #db, "mydata.db", lock
This causes a lock to be registered for the instance of the program that invokes it, and on mydata.db. If another program also connects to that database using the lock option it will sit and wait until the first program unlocks it by calling disconnect().
If any program attempts to connect to a database that is has already a connection to, a runtime error will occur and also the connections and locks for that program will be released.
To use this mechanism effectively your Run BASIC program should always connect to a database only when it is about to read or write to it and then disconnect as soon as it is done. It won't work to have a connection across web pages or in between user actions, which wouldn't be recommended in any case even if you're using Oracle or some other database server.
This option may be made available for other database types as they become available.
-Carl