Function to get exclusive lock in SQLite

你说的曾经没有我的故事 提交于 2021-02-08 09:39:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!