nonisolated(unsafe) static var logError: LogErrorFunction?
The error logging function.
static let resumeNotification: Notification.Name
When this notification is posted, databases which were opened with the observesSuspensionNotifications
configuration flag are resumed.
static var sqliteLibVersionNumber: CInt
An integer equal to SQLITE_VERSION_NUMBER
.
static let suspendNotification: Notification.Name
When this notification is posted, databases which were opened with the observesSuspensionNotifications
configuration flag are suspended.
static func isGRDBInternalTable(String) -> Bool
Returns whether a table is an internal GRDB table.
static func isSQLiteInternalTable(String) -> Bool
Returns whether a table is an internal SQLite table.
static func json(some SQLExpressible) -> SQLExpression
Validates and minifies a JSON string, with the JSON
SQL function.
static func jsonArray(some Collection<some SQLExpressible>) -> SQLExpression
Creates a JSON array with the JSON_ARRAY
SQL function.
static func jsonArray(some Collection<any SQLExpressible>) -> SQLExpression
Creates a JSON array with the JSON_ARRAY
SQL function.
static func jsonArrayLength(some SQLExpressible) -> SQLExpression
The number of elements in a JSON array, as returned by the JSON_ARRAY_LENGTH
SQL function.
static func jsonArrayLength(some SQLExpressible, atPath: some SQLExpressible) -> SQLExpression
The number of elements in a JSON array, as returned by the JSON_ARRAY_LENGTH
SQL function.
static func jsonGroupArray(some SQLExpressible, filter: (any SQLSpecificExpressible)?) -> SQLExpression
The JSON_GROUP_ARRAY
SQL function.
static func jsonGroupObject(key: some SQLExpressible, value: some SQLExpressible, filter: (any SQLSpecificExpressible)?) -> SQLExpression
The JSON_GROUP_OBJECT
SQL function.
static func jsonInsert(some SQLExpressible, some Collection<(key: String, value: any SQLExpressible)>) -> SQLExpression
The JSON_INSERT
SQL function.
static func jsonIsValid(some SQLExpressible) -> SQLExpression
The JSON_VALID
SQL function.
static func jsonObject(some Collection<(key: String, value: any SQLExpressible)>) -> SQLExpression
Creates a JSON object with the JSON_OBJECT
SQL function. Pass key/value pairs with a Swift collection such as a Dictionary
.
static func jsonPatch(some SQLExpressible, with: some SQLExpressible) -> SQLExpression
The JSON_PATCH
SQL function.
static func jsonQuote(some SQLExpressible) -> SQLExpression
Returns a valid JSON string with the JSON_QUOTE
SQL function.
static func jsonRemove(some SQLExpressible, atPath: some SQLExpressible) -> SQLExpression
The JSON_REMOVE
SQL function.
static func jsonRemove(some SQLExpressible, atPaths: some Collection<some SQLExpressible>) -> SQLExpression
The JSON_REMOVE
SQL function.
static func jsonReplace(some SQLExpressible, some Collection<(key: String, value: any SQLExpressible)>) -> SQLExpression
The JSON_REPLACE
SQL function.
static func jsonSet(some SQLExpressible, some Collection<(key: String, value: any SQLExpressible)>) -> SQLExpression
The JSON_SET
SQL function.
static func jsonType(some SQLExpressible) -> SQLExpression
The JSON_TYPE
SQL function.
static func jsonType(some SQLExpressible, atPath: some SQLExpressible) -> SQLExpression
The JSON_TYPE
SQL function.
var changesCount: Int
The number of rows modified, inserted or deleted by the most recent successful INSERT, UPDATE or DELETE statement.
let configuration: Configuration
The database configuration.
var debugDescription: String
let description: String
A description of this database connection.
var isInsideTransaction: Bool
A Boolean value indicating whether the database connection is currently inside a transaction.
var lastErrorCode: ResultCode
The last error code.
var lastErrorMessage: String?
The last error message.
var lastInsertedRowID: Int64
The rowID of the most recently inserted row.
var maximumStatementArgumentCount: Int
The maximum number of arguments accepted by an SQLite statement.
var sqliteConnection: SQLiteConnection?
The raw SQLite connection, suitable for the SQLite C API.
var totalChangesCount: Int
The total number of rows modified, inserted or deleted by all successful INSERT, UPDATE or DELETE statements since the database connection was opened.
var transactionDate: Date
The date of the current transaction.
func add(collation: DatabaseCollation)
Adds or redefines a collation.
func add(function: DatabaseFunction)
Adds or redefines a custom SQL function.
func add(tokenizer: (some FTS5CustomTokenizer).Type)
Add a custom FTS5 tokenizer.
func add(transactionObserver: some TransactionObserver, extent: TransactionObservationExtent)
Adds a transaction observer on the database connection, so that it gets notified of database changes and transactions.
func afterNextTransaction(onCommit: @escaping (Database) -> Void, onRollback: @escaping (Database) -> Void)
Registers closures to be executed after the next or current transaction completes.
func allStatements(literal: SQL) throws -> SQLStatementCursor
Returns a cursor of prepared statements.
func allStatements(sql: String, arguments: StatementArguments?) throws -> SQLStatementCursor
Returns a cursor of prepared statements.
func alter(table: String, body: (TableAlteration) -> Void) throws
Modifies a database table.
func backup(to: Database, pagesPerStep: CInt, progress: ((DatabaseBackupProgress) throws -> Void)?) throws
Copies the database contents into another database.
func beginTransaction(TransactionKind?) throws
Begins a database transaction.
func cachedStatement(literal: SQL) throws -> Statement
Returns a prepared statement that can be reused.
func cachedStatement(sql: String) throws -> Statement
Returns a prepared statement that can be reused.
func checkForeignKeys() throws
Throws an error if there exists a foreign key violation in the database.
func checkForeignKeys(in: String, in: String?) throws
Throws an error if there exists a foreign key violation in the table.
func checkpoint(Database.CheckpointMode, on: String?) throws -> (walFrameCount: Int, checkpointedFrameCount: Int)
Runs a WAL checkpoint.
func clearSchemaCache()
Clears the database schema cache.
func columns(in: String, in: String?) throws -> [ColumnInfo]
Returns the columns in a table or a view.
func commit() throws
Commits a database transaction.
func create(index: String, on: String, columns: [String], options: IndexOptions, condition: (any SQLExpressible)?) throws
Creates an index on the specified table and columns.
func create(index: String, on: String, columns: [String], unique: Bool, ifNotExists: Bool, condition: (any SQLExpressible)?) throws
Creates an index on the specified table and columns.
func create(index: String, on: String, expressions: [any SQLExpressible], options: IndexOptions, condition: (any SQLExpressible)?) throws
Creates an index on the specified table and expressions.
func create(indexOn: String, columns: [String], options: IndexOptions, condition: (any SQLExpressible)?) throws
Creates an index with a default name on the specified table and columns.
func create(table: String, options: TableOptions, body: (TableDefinition) throws -> Void) throws
Creates a database table.
func create(table: String, temporary: Bool, ifNotExists: Bool, withoutRowID: Bool, body: (TableDefinition) throws -> Void) throws
Creates a database table.
func create(view: String, options: ViewOptions, columns: [String]?, as: SQLSubqueryable) throws
Creates a database view.
func create(view: String, options: ViewOptions, columns: [String]?, asLiteral: SQL) throws
Creates a database view.
func create(virtualTable: String, ifNotExists: Bool, using: String) throws
Creates a virtual database table.
func create<Module>(virtualTable: String, ifNotExists: Bool, using: Module, ((Module.TableDefinition) throws -> Void)?) throws
Creates a virtual database table.
func create(virtualTable: String, options: VirtualTableOptions, using: String) throws
Creates a virtual database table.
func create<Module>(virtualTable: String, options: VirtualTableOptions, using: Module, ((Module.TableDefinition) throws -> Void)?) throws
Creates a virtual database table.
func drop(index: String) throws
Deletes a database index.
func drop(indexOn: String, columns: [String]) throws
Deletes the database index on the specified table and columns if exactly one such index exists.
func drop(table: String) throws
Deletes a database table.
func drop(view: String) throws
Deletes a database view.
func dropFTS4SynchronizationTriggers(forTable: String) throws
Deletes the synchronization triggers for a synchronized FTS4 table.
func dropFTS5SynchronizationTriggers(forTable: String) throws
Deletes the synchronization triggers for a synchronized FTS5 table.
func dumpContent(format: some DumpFormat, to: (any TextOutputStream)?) throws
Prints the contents of the database.
func dumpRequest(some FetchRequest, format: some DumpFormat, to: (any TextOutputStream)?) throws
Prints the results of a request.
func dumpSQL(SQL, format: some DumpFormat, to: (any TextOutputStream)?) throws
Prints the results of all statements in the provided SQL.
func dumpSchema(to: (any TextOutputStream)?) throws
Prints the schema of the database.
func execute(literal: SQL) throws
Executes one or several SQL statements.
func execute(sql: String, arguments: StatementArguments) throws
Executes one or several SQL statements.
func foreignKeyViolations() throws -> RecordCursor<ForeignKeyViolation>
Returns a cursor over foreign key violations in the database.
func foreignKeyViolations(in: String, in: String?) throws -> RecordCursor<ForeignKeyViolation>
Returns a cursor over foreign key violations in the table.
func foreignKeys(on: String, in: String?) throws -> [ForeignKeyInfo]
Returns the foreign keys defined on table named tableName
.
func inSavepoint(() throws -> TransactionCompletion) throws
Wraps database operations inside a savepoint.
func inTransaction(TransactionKind?, () throws -> TransactionCompletion) throws
Wraps database operations inside a database transaction.
func indexes(on: String, in: String?) throws -> [IndexInfo]
The indexes on table named tableName
.
func makeFTS5Pattern(rawPattern: String, forTable: String) throws -> FTS5Pattern
Creates an FTS5 pattern from a raw pattern string.
func makeStatement(literal: SQL) throws -> Statement
Returns a new prepared statement that can be reused.
func makeStatement(sql: String) throws -> Statement
Returns a new prepared statement that can be reused.
func makeTokenizer(FTS5TokenizerDescriptor) throws -> any FTS5Tokenizer
Creates an FTS5 tokenizer, given its descriptor.
func notifyChanges(in: some DatabaseRegionConvertible) throws
Notifies that some changes were performed in the provided database region.
func primaryKey(String, in: String?) throws -> PrimaryKeyInfo
The primary key for table named tableName
.
func readOnly<T>(() throws -> T) throws -> T
Executes read-only database operations, and returns their result after they have finished executing.
func registerAccess(to: @autoclosure () -> some DatabaseRegionConvertible) throws
Reports the database region to ValueObservation
.
func reindex(collation: DatabaseCollation) throws
Deletes and recreates from scratch all indices that use this collation.
func reindex(collation: Database.CollationName) throws
Deletes and recreates from scratch all indices that use this collation.
func releaseMemory()
Frees as much memory as possible.
func remove(collation: DatabaseCollation)
Removes a collation.
func remove(function: DatabaseFunction)
Removes a custom SQL function.
func remove(transactionObserver: some TransactionObserver)
Removes a transaction observer from the database connection.
func rename(table: String, to: String) throws
Renames a database table.
func rollback() throws
Rollbacks a database transaction.
func schemaVersion() throws -> Int32
Returns the current schema version (PRAGMA schema_version
).
func table(String, hasUniqueKey: some Collection<String>) throws -> Bool
Returns whether a sequence of columns uniquely identifies a row.
func tableExists(String, in: String?) throws -> Bool
Returns whether a table exists
func trace(options: TracingOptions, ((TraceEvent) -> Void)?)
Registers a tracing function.
func triggerExists(String, in: String?) throws -> Bool
Returns whether a trigger exists, in the main or temp schema, or in an attached database.
func viewExists(String, in: String?) throws -> Bool
Returns whether a view exists, in the main or temp schema, or in an attached database.