Hi guys!
I want to make a similar menu but I don't know what components it is.
Push buttons?
Inline buttons?
Menu items?
Do you know how to do that please?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi guys,
🙏I have a problem with repeated saving to the database. If I do the first update it is OK, but after the second attempt the update fails and the console says "Failed to commit transaction: database is locked".
Here is my function:
func updateMapCoordinates(radius: Int32) {
// Otevření databáze, pokud není otevřená
guard db != nil else {
print("Database connection is nil")
return
}
var statement: OpaquePointer? = nil
let updateQuery = "UPDATE \(mapTable) SET radius = ? WHERE id = 1;"
// Začátek transakce
if sqlite3_exec(db, "BEGIN TRANSACTION", nil, nil, nil) != SQLITE_OK {
let errorMessage = String(cString: sqlite3_errmsg(db))
print("Failed to begin transaction: \(errorMessage)")
return
}
if sqlite3_prepare_v2(db, updateQuery, -1, &statement, nil) == SQLITE_OK {
sqlite3_bind_int(statement, 1, radius)
print("uložím \(radius)")
if sqlite3_step(statement) == SQLITE_DONE {
print("Coordinates saved successfully")
} else {
let errorMessage = String(cString: sqlite3_errmsg(db))
print("Failed to save coordinates: \(errorMessage)")
}
} else {
let errorMessage = String(cString: sqlite3_errmsg(db))
print("SAVE statement could not be prepared: \(errorMessage)")
}
// Finalizace statementu
sqlite3_finalize(statement)
// Ukončení transakce
if sqlite3_exec(db, "COMMIT", nil, nil, nil) != SQLITE_OK {
let errorMessage = String(cString: sqlite3_errmsg(db))
print("Failed to commit transaction: \(errorMessage)")
sqlite3_exec(db, "ROLLBACK", nil, nil, nil)
}
}
Hi guys,
please help me with sqlite database. When I save the data in the table, it always saves the wrong data in the columns. They don't match the submitted data at all. I don't know where I am making a mistake.
Thank you!
DatabaseManager
ViewController