DatabaseConnection

Exposes the Database Connection and the associated Encryption APIs.

Properties

Link copied to clipboard
abstract val changes: Long

Number of rows modified, inserted or deleted by the most recently completed INSERT, UPDATE or DELETE statement.

Link copied to clipboard

Configuration of the connection.

Link copied to clipboard
abstract val fileControl: FileControl

File control object that allows direct call to the xFileControl.

Link copied to clipboard
abstract val isAutocommit: Boolean

Whether the connection is in autocommit mode.

Link copied to clipboard
abstract val isInterrupted: Boolean

Whether an interrupt is currently in effect.

Link copied to clipboard
abstract val lastError: LastError

Most recent error information.

Link copied to clipboard
abstract var lastInsertRowid: Long

Rowid of the most recent successful INSERT into a rowid table or virtual table on this connection.

Link copied to clipboard
abstract val totalChanges: Long

Total number of rows inserted, modified or deleted by all INSERT, UPDATE or DELETE statements completed since the database connection was opened, including those executed as part of trigger programs.

Link copied to clipboard
abstract val wal: WriteAheadLog

Write-Ahead Log operating on this connection.

Functions

Link copied to clipboard
expect abstract fun close()
Link copied to clipboard
abstract fun createCollation(name: String, encoding: SqliteTextEncoding.CreateCollation, collation: Collation)

Creates or replaces a collation.

Link copied to clipboard
abstract fun createFunction(name: String, argumentCount: Int, encoding: SqliteFunctionTextEncoding, function: AggregateFunction)

Creates or updates an aggregate function.

abstract fun createFunction(name: String, argumentCount: Int, encoding: SqliteFunctionTextEncoding, function: ScalarFunction)

Creates or updates a scalar function.

abstract fun createFunction(name: String, argumentCount: Int, encoding: SqliteFunctionTextEncoding, function: WindowFunction)

Creates or updates a window function.

Link copied to clipboard
abstract fun createModule(name: String, version: SqliteModuleVersion = SqliteModuleVersion.VERSION_4, module: VirtualTableModule.Eponymous)
abstract fun createModule(name: String, version: SqliteModuleVersion = SqliteModuleVersion.VERSION_4, module: VirtualTableModule.EponymousOnly)
abstract fun createModule(name: String, version: SqliteModuleVersion = SqliteModuleVersion.VERSION_4, module: VirtualTableModule.Regular)

Creates or replaces a virtual table module.

Link copied to clipboard
abstract fun createSnapshot(database: String? = null): Snapshot

Records the current state of the given database and returns a Snapshot.

Link copied to clipboard

Deletes the collation created using the same parameters.

Link copied to clipboard
abstract fun deleteFunction(name: String, argumentCount: Int, encoding: SqliteFunctionTextEncoding, isWindowFunction: Boolean = false)

Deletes the function that was created with the same arguments. If the function is a window function, then isWindowFunction should be set to true.

Link copied to clipboard
abstract fun deleteModule(name: String)

Deletes the module for name.

Link copied to clipboard
abstract fun deleteModules(keep: Set<String>)

Deletes all the modules excepts those that get their name listed in keep.

Link copied to clipboard
abstract fun deserialize(serializedDatabase: Buffer, database: String? = null, databaseSize: Long = serializedDatabase.byteSize, bufferSize: Long = databaseSize, flags: SqliteDeserializeFlag? = null)

Disconnects from database and then reopens database as an in-memory database based on the serialization contained in serializedDatabase. The serializedDatabase is databaseSize bytes in size. bufferSize is the size of the buffer serializedDatabase, which might be larger than databaseSize. If bufferSize is larger than databaseSize, and the SqliteDeserializeFlag.READONLY bit is not set in flags, then SQLite is permitted to add content to the in-memory database as long as the total size does not exceed bufferSize bytes.

Link copied to clipboard
abstract fun execute(sql: String, callback: Exec? = null)

Runs zero or more UTF-8 encoded, semicolon-separated SQL statements from sql. If callback is not null then it is invoked for each result row coming out of the evaluated SQL statements.

Link copied to clipboard
abstract fun flushCache()

Writes any dirty pages in the pager-cache that are not currently in use. The operation only take places if there is a write-transaction open at the time this function is called.

Link copied to clipboard
abstract fun getFileName(database: String = MAIN_DB_NAME): FileName?

Returns the absolute pathname of the database database of this connection.

Link copied to clipboard
abstract fun getLimit(limit: SqliteRuntimeLimit): Int

Returns the current value of the given limit category.

Link copied to clipboard
abstract fun getName(index: Int): String?

Returns the schema name for the indexth database on this connection.

Link copied to clipboard
abstract fun getStatus(option: SqliteDbStatusOption, reset: Boolean = false): Status

Returns the status for the given options.

Link copied to clipboard
abstract fun getTransactionState(database: String? = null): SqliteTransactionState

Returns the current transaction state of database.

Link copied to clipboard
abstract fun interrupt()

Causes any pending database operation to abort and return at its earliest opportunity.

Link copied to clipboard
abstract fun isReadOnly(database: String): Boolean

Returns true if the database database is read-only, or false If it is read/write.

Link copied to clipboard
abstract fun openBlob(tableName: String, columnName: String, rowid: Long, database: String = MAIN_DB_NAME, flags: SqliteBlobOpenFlag = SqliteBlobOpenFlag.READONLY): Blob

Opens a Blob.

Link copied to clipboard
abstract fun openSnapshot(snapshot: Snapshot, database: String? = null)

Starts a new read transaction or upgrades an existing one for database of this database such that the read transaction refers to historical snapshot, rather than the most recent change to the database.

Link copied to clipboard
abstract fun prepare(sql: String, flags: SqlitePrepareFlag? = null): PreparedStatement

Creates and returns a PreparedStatement.

Link copied to clipboard
abstract fun recoverSnapshots(database: String? = null)

Attempts to scan the WAL file associated with database of this connection and make all valid snapshots available to openSnapshot.

Link copied to clipboard
abstract fun releaseMemory()

Attempts to free as much heap memory as possible from this connection.

Link copied to clipboard
abstract fun serialize(flags: SqliteSerializeFlag? = null, database: String? = null): SerializeResult

Returns a Buffer that is a serialization of the given database.

Link copied to clipboard
abstract fun setAuthorizer(handler: Authorizer?)

Sets the callback that get invoked whenever an SQL statements is being compiled by prepare.

Link copied to clipboard
abstract fun setAutovacuumPages(handler: AutovacuumPages?)

Sets the callback that is invoked prior to each autovacuum of the database file.

Link copied to clipboard
abstract fun setBusyHandler(handler: BusyHandler?)

Sets the callback that might be invoked whenever an attempt is made to access a database table associated with this connection when another thread or process has the table locked.

Link copied to clipboard
abstract fun setBusyTimeout(millis: Int)

Sets a BusyHandler that sleeps for a specified amount of time when a table is locked. Any BusyHandler previously passed to setBusyHandler is replaced.

Link copied to clipboard

Sets a BusyHandler that sleeps for a specified amount of time when a table is locked. Any BusyHandler previously passed to DatabaseConnection.setBusyHandler is replaced.

Link copied to clipboard
abstract fun setCollationNeeded(handler: CollationNeeded?)

Sets the callback that get invoked whenever an undefined collation sequence is required.

Link copied to clipboard
abstract fun setCommitHook(handler: CommitHook?)

Sets the callback that get invoked whenever an undefined collation sequence is required.

Link copied to clipboard
abstract fun setExtendedResultCodesEnabled(enabled: Boolean)

Enables or disables the extended result codes.

Link copied to clipboard
abstract fun setKey(key: ByteArray, size: Int = key.size, database: String = MAIN_DB_NAME)

Sets the database key to use when accessing an encrypted database.

Link copied to clipboard
abstract fun setLimit(limit: SqliteRuntimeLimit, value: Int)

Sets the value of the given limit category.

Link copied to clipboard
abstract fun setPreupdateHook(handler: PreupdateHook?)

Sets the callback that is invoked prior to each INSERT, UPDATE, and DELETE operation.

Link copied to clipboard
abstract fun setProgressHandler(operationCount: Int, handler: ProgressHandler?)

Sets the callback that is invoked periodically during long-running calls.

Link copied to clipboard
abstract fun setReKey(key: ByteArray, size: Int = key.size, database: String = MAIN_DB_NAME)

Changes the database encryption key.

Link copied to clipboard
abstract fun setRollbackHook(handler: RollbackHook?)

Sets the callback that get invoked whenever a transaction is rolled back.

Link copied to clipboard
abstract fun setTrace(eventCodes: SqliteTraceEventCode?, handler: Trace?)

Sets the callback that get invoked whenever any of the events identified by eventCodes occur.

Link copied to clipboard
abstract fun setUpdateHook(handler: UpdateHook?)

Sets the callback that is invoked whenever a row is updated, inserted or deleted in a rowid table.

Link copied to clipboard
abstract fun tableColumnMetadata(table: String, column: String, database: String? = null): TableColumnMetadata

Returns information about the column column of table table in database database.