Reputation: 898
I want to delete a row with the given value (contactID
), which is also the primary key, in SQLite.Swift:
let delRowCo = ContactTable.filter(ContactID == contactID)
try db.run(delRowCo.delete())
The given contactID
surely exists, but it doesn't delete the row ...
Upvotes: 0
Views: 309
Reputation: 12502
Try this too.
let mytable = Table("ContactTable")
let delRowCo = mytable.filter(ContactID == 'contact_id')
try db.run(delRowCo.delete())
Upvotes: 0
Reputation: 12502
Try with some error handling. You'll catch if there are any errors.
do {
if try db.run(delRowCo.delete()) > 0 {
print("deleted")
} else {
print("row not found")
}
} catch {
print("delete failed: \(error)")
}
Upvotes: 1