Library Initialization
Before an application can use the SQLite library to do anything, the library must first be initialized. This process allocates some standard resources and sets up any OS-specific data structures. By default, most major API function calls will automatically initialize the library, if it has not already been initialized. It is considered a good practice to manually initialize the library, however.
-
int sqlite3_initialize( )
Initializes the SQLite library. This function should be called prior to any other function in the SQLite API. Calling this function after the library has already been initialized is harmless. This function can be called after a shutdown to reinitialize the library. A return value of
SQLITE_OK
indicates success.
When an application is finished using the SQLite library, the library should be shut down.
-
int sqlite3_shutdown( )
Releases any resources allocated by
sqlite3_initialize()
. Calling this function before the library has been initialized or after the library has already been shut down is harmless. A return value ofSQLITE_OK
indicates success.
Because of the automatic initialization features, many
applications never call either of these functions. Rather, they call
sqlite3_open()
, or one of the other
primary functions, and depend on the library to automatically initialize
itself. In most cases this is safe enough, but for maximum compatibility it
is best to call these functions
explicitly
.
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.