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?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
As of Python 3.4.0 you can open the database in read only mode with the following:
Also see the documentation.
Workaround for Python 2.x:
Not posix, but available on Linux, OS/X and most modern unixes.
As by the link given by @Chris, no. But there is another wrapper for sqlite3, which is less PEP 249-compliant and that wraps sqlite3 more tightly, assimilating new features of the engine: http://code.google.com/p/apsw/ . That wrapper does support opening the database in read-only mode, plus other niceties.
Somewhat related, note that you can enable/disable modifications dynamically with a pragma: