SQLite数据库“Database is locked”解决办法
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了SQLite数据库“Database is locked”解决办法,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1514字,纯文字阅读大概需要3分钟。
内容图文
![SQLite数据库“Database is locked”解决办法](/upload/InfoBanner/zyjiaocheng/525/cb44d2fa1f9347609ff604009911510c.jpg)
“Database is locked” errors
SQLite is meant to be a lightweight database, and thus can’t support a high level of concurrency. OperationalError: database is locked errors indicate that your application is experiencing more concurrency than sqlite can handle in default configuration. This error means that one thread or process has an exclusive lock on the database connection and another thread timed out waiting for the lock the be released.
Python’s SQLite wrapper has a default timeout value that determines how long the second thread is allowed to wait on the lock before it times out and raises the OperationalError: database is locked error.
If you’re getting this error, you can solve it by:
Switching to another database backend. At a certain point SQLite becomes too “lite” for real-world applications, and these sorts of concurrency errors indicate you’ve reached that point.
Rewriting your code to reduce concurrency and ensure that database transactions are short-lived.
Increase the default timeout value by setting the timeout database option:
‘OPTIONS‘: {
# ...
‘timeout‘: 20,
# ...
}
This will make SQLite wait a bit longer before throwing “database is locked” errors; it won’t really do anything to solve them.
SQLite数据库“Database is locked”解决办法
标签:red The get ror real error nal efault tab
本文系统来源:https://www.cnblogs.com/JeromeLong/p/13195521.html
内容总结
以上是互联网集市为您收集整理的SQLite数据库“Database is locked”解决办法全部内容,希望文章能够帮你解决SQLite数据库“Database is locked”解决办法所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。