useConnection

abstract suspend fun <T> useConnection(readOnly: Boolean = false, block: suspend (SQLiteConnectionLease) -> T): T(source)

Obtains a connection from the read pool or an exclusive reference on the write connection.

This is useful when you need full control over the raw statements to use.

Misusing this API, for instance by not cleaning up transactions started on the underlying connection with a BEGIN statement or forgetting to close it, can disrupt the rest of the PowerSync SDK. For this reason, this method should only be used if absolutely necessary.