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:

let configuration = Configuration(busyMode: .timeout(1))
let dbQueue = DatabaseQueue(path: "...", configuration: configuration)

Relevant SQLite documentation:

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

    Declaration

    Swift

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

    Declaration

    Swift

    case timeout(TimeInterval)