Open sqlite database in read-only mode

Source: Internet
Author: User

Add Sunisoft online update software to the software project. When the software version is updated, the user automatically detects and downloads the new software version. The software features are relatively simple, mainly reading sqlite files. However, during use, it is found that as long as you connect to the sqlite database, the update software will think that the sqlite database file has been modified, which is inconsistent with the version on the server and needs to be updated. Compared with md5, the database is not modified when it is opened. Later, the test showed that as long as the file is opened in writable mode, Sunisoft considers that the file has been modified, even if it is not written after it is opened. Find the cause and then solve it easily. Since the software does not need to perform some operations on the sqlite file, it is mainly a query operation, so you can connect to the sqlite database in read-only mode. Sqlite3 provides a read-only interface for opening files. [Cpp] int sqlite3_open_v2 (const char * filename,/* Database filename (UTF-8) */sqlite3 ** ppDb,/* OUT: SQLite db handle */int flags, /* Flags */www.2cto.com const char * zVfs/* Name of VFS module to use */); the first parameter is the database file path, and the second parameter is the output parameter, database Operation pointer address. The third parameter is the database access mode. you can configure this parameter to open a database in read-only mode. It can be SQLITE_OPEN_READONLY, SQLITE_OPEN_READWRITE, and SQLITE_OPEN_READWRITE. | one of SQLITE_OPEN_CREATE is used to control the database access mode, it can be used with SQLITE_OPEN_NOMUTEX, SQLITE_OPEN_FULLMUTEX, SQLITE_OPEN_SHAREDCACHE, and SQLITE_OPEN_PRIVATECACHE. The fourth parameter zVfs allows the customer's application to name a Virtual File System module to connect to the database. VFS is an abstraction layer between SQlite library and underlying storage systems (such as a file system). Generally, a customer application can simply pass a NULL pointer to this parameter, to use the default VFS module.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.