BusyMode

public enum BusyMode

When there are several connections to a database, a connection may try to access the database while it is locked by another connection.

The BusyMode enum describes the behavior of GRDB when such a situation occurs:

  • .immediateError: The SQLITE_BUSY error is immediately returned to the connection that tries to access the locked database.

  • .timeout: The SQLITE_BUSY error will be returned only if the database remains locked for more than the specified duration.

  • .callback: Perform your custom lock handling.

To set the busy mode of a database, use Configuration:

// Wait 1 second before failing with SQLITE_BUSY
let configuration = Configuration(busyMode: .timeout(1))
let dbQueue = DatabaseQueue(path: "...", configuration: configuration)

Relevant SQLite documentation: