我们如何知道sqlite DB的锁定状态? [英] How do we know the lock status of sqlite DB?

查看:371
本文介绍了我们如何知道sqlite DB的锁定状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1)是否存在实用程序或任何方法来了解sqlite db的当前锁定状态 ?.
2)另外,是否有办法知道是否有其他进程正在使用DB?

1)Is there a pragma or any way to know the current lock state of sqlite db?.
2)Also, Is there a way to know if any other process is using the DB?.

推荐答案

关于#1:否,因为您得到的答案会立即过时(即,如果您得到的答案是没有锁定数据库" ,其他人可能会过来并立即将其锁定,从而给您留下不好的信息.

Regarding #1: No, because the answer you got would be immediately stale (that is if you got an answer of "no the database isn't locked", someone else could come along and immediately lock it, leaving you with bad info).

正确的方法是简单地尝试操作(可以选择超时),看看操作是否成功.

The correct approach is to simply try your operation (optionally with a timeout) and see if it succeeds.

这篇关于我们如何知道sqlite DB的锁定状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆