问题
I was trying to get the exclusive lock for the SQLite database.
I used sqlite3_db_mutex(db); and sqlite3_mutex_try(mutexObj) function to acquire lock,
but when I tried to execute query from other shell to the same database, I was able insert row in the table,read the data from table
I want is to get the LOCK to the database, so that during that time, no-one can make any change to the database, while I've acquired the lock. It is possible in Sqlite ????
回答1:
sqlite3_db_mutex
locks that connection, and is intended to be used for multiple threads using the same connection.
To lock the database, execute BEGIN EXCLUSIVE.
来源:https://stackoverflow.com/questions/21886157/function-to-get-exclusive-lock-in-sqlite