gistlib
main.swiftimport SQLite3 func executeQuery(using db: OpaquePointer?, with query: String) { var stmt: OpaquePointer? if sqlite3_prepare_v2(db, query, -1, &stmt, nil) == SQLITE_OK { if sqlite3_step(stmt) == SQLITE_DONE { print("Query executed successfully") } else { print("Error executing query") } } else { print("Error preparing query") } sqlite3_finalize(stmt) } // Update function func updateRecord(using db: OpaquePointer?, with query: String) { executeQuery(using: db, with: query) } // Delete function func deleteRecord(using db: OpaquePointer?, with query: String) { executeQuery(using: db, with: query) } 690 chars26 lines
import SQLite3 func executeQuery(using db: OpaquePointer?, with query: String) { var stmt: OpaquePointer? if sqlite3_prepare_v2(db, query, -1, &stmt, nil) == SQLITE_OK { if sqlite3_step(stmt) == SQLITE_DONE { print("Query executed successfully") } else { print("Error executing query") } } else { print("Error preparing query") } sqlite3_finalize(stmt) } // Update function func updateRecord(using db: OpaquePointer?, with query: String) { executeQuery(using: db, with: query) } // Delete function func deleteRecord(using db: OpaquePointer?, with query: String) { executeQuery(using: db, with: query) }
gistlibby LogSnag