以只读模式从python打开sqlite3数据库 [英] Opening sqlite3 database from python in read-only mode
本文介绍了以只读模式从python打开sqlite3数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在使用 C/C++ 中的 sqlite3 时,我了解到它具有只读模式选项,这对于避免意外数据损坏非常方便.Python绑定中有这样的东西吗?
While using sqlite3 from C/C++ I learned that it has a open-in-read-only mode option, which is very handy to avoid accidental data-corruption. Is there such a thing in the Python binding?
推荐答案
从 Python 3.4.0 开始,您可以使用以下命令以只读模式打开数据库:
As of Python 3.4.0 you can open the database in read only mode with the following:
db = sqlite3.connect('file:/path/to/database?mode=ro', uri=True)
另请参阅文档.
这篇关于以只读模式从python打开sqlite3数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文