Skip to main content

SQLiter

Connection Configuration

The database configuration used to open a connection supplies a number of generally sane defaults, but there are a quite a number of properties that could be overridden.

Required parameters

NameTypeDescription
nameString?The database filename to open, or the name to assign to an in-memory database
versionIntThe expected database schema version
create(DatabaseConnection) -> UnitLambda to call if the database schema needs to be created

Optional parameters

NameTypeDescription
upgrade(DatabaseConnection, Int, Int) -> UnitDefaults to doing nothing when versions of the database don’t match. Supply your own upgrade lambda for other migration strategies.
inMemoryBooleanDefaults to false. Set to true if you need an in-memory database
journalModeJournalModeDefaults to JournalMode.WAL
extendedConfigExtendedSee below
loggingConfigLoggingSee below
lifecycleConfigLifecycleSee below
encryptionConfigEncryptionSee below

Extended configuration

NameTypeDescription
foreignKeyConstraintsBooleanDefaults to false
busyTimeoutIntDefaults to 5000
pageSizeInt?Defaults to null
basePathString?Defaults to null
synchronousFlagSynchronousFlag?Defaults to null
recursiveTriggersBooleanDefaults to false
lookasideSlotSizeIntDefaults to -1
lookasideSlotCountIntDefaults to -1

Logging

NameTypeDescription
loggerLoggerDefaults to WarningLogger (errors are enabled, verbose logging not)
verboseDataCallsBooleanDefaults to false. SQLiter will verbose log execution of calls in the sqlite statement if this is enabled.

Lifecycle

NameTypeDescription
onCreateConnection(DatabaseConnection) -> UnitCalled when the connection is opened, but before version/migration checking
onCloseConnection(DatabaseConnection) -> UnitCalled after the sqlite connection is closed

Encryption

NameTypeDescription
keyString?Used for creating encrypted databases or accessing an existing encrypted database.
rekeyString?Used to encrypt an existing unencrypted database, change the encryption key of an existing encrypted database or remove encryption from an existing encrypted database.