Name
sqlite3_open() — Open a database file
Definition
int sqlite3_open( const char* filename, sqlite3** db_ref ); int sqlite3_open16( const void* filename, sqlite3** db_ref );
-
filename
The path and filename of the database file as a UTF-8 or UTF-16 encoded string.
-
db_ref
A reference to a database connection. If the database is successfully opened, the database connection will be passed back.
- Returns
An SQLite result code.
Description
These functions open a database and create a new database connection. If the filename does not exist, it will be created. The file will be opened read/write if possible. If not, the file will be opened read-only.
If the filename is :memory:
,
a temporary, in-memory database will be created. The database
will automatically be deleted when the database connection is
closed. Each call to open will create a new in-memory database.
Each in-memory database is accessible from only one database
connection.
If the filename is NULL or an empty string (""
), a temporary, file-backed
database will be created. This is very similar to an in-memory
database, only the database is allowed to page out to disk. This
allows the database to grow to much larger sizes without
worrying about memory consumption.
These functions are considered legacy APIs. It is recommended
that all new development use sqlite3_open_v2()
.
See Also
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.