Name

sqlite3_open_v2() — Open a database file

Definition

int sqlite3_open_v2( const char* filename, sqlite3** db_ref,
                          int flags, const char* vfs );
filename

The path and filename of the database file as a UTF-8 encoded string.

db_ref

A reference to a database connection. If the database is successfully opened, the database connection will be passed back.

flags

A series of flags that can be used to control how the database file is open.

vfs

The name of the VFS (Virtual File System) module to use. A NULL will result in the default module.

Returns

An SQLite result code.

Description

This function is very similar to sqlite3_open(), but provides better control over how the database file is opened. The flags parameter controls the state of the opened file, while the vfs parameter allows the application to specify a VFS (virtual file system) driver.

The flag parameter consists of several bit-flags that can be or’ed together. The application must specify one of the following flag combinations:

SQLITE_OPEN_READONLY

Open the file read-only. The file must already exist.

SQLITE_OPEN_READWRITE

Attempt to open the file read/write. If this is not possible, open the file read-only. Opening the file read-only will not result in an error. The file must already exist.

SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE

Attempt to open the file read/write. If it does not exist, create the file. If the file does exist, but permissions do not allow read/write access, open the file read-only. Opening the file read-only ...

Get Using SQLite now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.