Chapter 3. Driver options

Your application has to initialize libdbi drivers by setting some driver options with the dbi_conn_set_option() and the dbi_conn_set_option_numeric() library functions. The sqlite driver supports the following options:

dbname

The name of the database you want to work with. As a SQLite database corresponds to one file in your filesystem, dbname can be any legal filename. If the database/file doesn't exist when you first try to access it, SQLite will create it on the fly.

It is important to understand that the full path of the database is composed of sqlite3_dbdir and dbname. Therefore dbname should not contain the full path of a file, but just the name.

sqlite3_dbdir

This is the directory that contains all sqlite databases. Use the full path please. If this option is not specified, a compile-time default directory will be used. By default, this directory (usually /usr/local/var/lib/libdbi/sqlite3) has read and write permissions for everyone with the sticky bit set. If this is not suitable for your application, use a custom directory with your preferred permissions instead.

Note: It is necessary to keep all sqlite databases in one directory to make it possible to list all existing databases through the libdbi API. However, you are free to open more than one connection simultaneously, each one using a different setting of sqlite3_dbdir.

timeout (numeric)

The connection timeout in seconds.

sqlite3_timeout (numeric)

The design of SQLite3 does not allow fully concurrent access by two clients. However, if the timeout is larger than zero, the second client will wait for the given amount of time for the first client to release its lock, if necessary. If the timeout is set to zero, the second client will return immediately, indicating a busy status. The numerical value of this option specifies the timeout in milliseconds.

Note: This option is deprecated. Use the generic option timeout instead. In the current implementation, sqlite3_timeout overrides timeout if both are set. Please be aware that these options use different time scales.