SQLite3 Driver Config

interface SQLite3DriverConfig {
    explicitWrite: boolean;
    fileMustExist: boolean;
    filename: string;
    pragmas: string[];
    prefix: string;
    timeout: number;
    verbose: undefined | ((message?, ...additionalArgs) => void);
    wal: boolean;
}

Properties

explicitWrite: boolean

Open explicitly for writing.

By default, the driver will always open the DB as readonly, and attempt to open another link to perform write operations. If you know that only one instance will be writing, you can force the driver to open for writing by default, which will block any other instance from opening it for writing.

One thing to note is that starting a transaction is a write operation, so as long as an instance is in a transaction, no other instances can write.

PubSub also needs to open the DB, and it only needs read access.

fileMustExist: boolean

If the file does not exist, an Error will be thrown instead of creating a new file.

This option is ignored for in-memory, temporary, or readonly database connections.

filename: string

The filename of the SQLite3 DB. Use ':memory:' for an in-memory DB.

pragmas: string[]

Additional pragma statements to run upon connection.

The default pragmas:

  • journal_mode = WAL; (if wal is set to true)
  • encoding = "UTF-8";
  • foreign_keys = 1;
  • case_sensitive_like = 1;

(Don't include the PRAGMA keyword, but do include the semicolon.)

prefix: string

The SQLite3 table name prefix.

timeout: number

The timeout to use for waiting for the DB to become available.

verbose: undefined | ((message?, ...additionalArgs) => void)

Function that gets called with every SQL string executed.

Type declaration

    • (message?, ...additionalArgs): void
    • Parameters

      • Optional message: any
      • Rest ...additionalArgs: any[]

      Returns void

wal: boolean

Turn on WAL mode.

This will generally increase performance, but does mean that the DB must be on a local disk.

See: https://www.sqlite.org/wal.html