Add changes & totalChanges properties for connection

This commit is contained in:
2025-11-11 16:28:51 +02:00
parent b41d772f7f
commit e48c37aca4
3 changed files with 75 additions and 0 deletions

View File

@@ -131,6 +131,14 @@ extension Connection: ConnectionProtocol {
sqlite3_db_readonly(connection, "main") == 1
}
public var changes: Int64 {
sqlite3_changes64(connection)
}
public var totalChanges: Int64 {
sqlite3_total_changes64(connection)
}
public static func initialize() throws(SQLiteError) {
let status = sqlite3_initialize()
guard status == SQLITE_OK else {

View File

@@ -12,6 +12,8 @@ import Foundation
///
/// - ``isAutocommit``
/// - ``isReadonly``
/// - ``changes``
/// - ``totalChanges``
///
/// ### Accessing PRAGMA Values
///
@@ -84,6 +86,14 @@ public protocol ConnectionProtocol: AnyObject {
/// - SeeAlso: [Determine if a database is read-only](https://sqlite.org/c3ref/db_readonly.html)
var isReadonly: Bool { get }
/// The number of rows modified by the most recent write operation.
/// - SeeAlso: [Count The Number Of Rows Modified](https://sqlite.org/c3ref/changes.html)
var changes: Int64 { get }
/// The total number of rows modified since this connection was opened.
/// - SeeAlso: [Total Number Of Rows Modified](https://sqlite.org/c3ref/total_changes.html)
var totalChanges: Int64 { get }
// MARK: - PRAGMA Accessors
/// The busy timeout of the connection, in milliseconds.