我想在 SQLite.Swift 中删除具有给定值 ( contactID
) 的行,这也是主键:
let delRowCo = ContactTable.filter(ContactID == contactID)
try db.run(delRowCo.delete())
给定的contactID
肯定存在,但它不会删除该行...
我想在 SQLite.Swift 中删除具有给定值 ( contactID
) 的行,这也是主键:
let delRowCo = ContactTable.filter(ContactID == contactID)
try db.run(delRowCo.delete())
给定的contactID
肯定存在,但它不会删除该行...
尝试一些错误处理。如果有任何错误,您会发现。
do {
if try db.run(delRowCo.delete()) > 0 {
print("deleted")
} else {
print("row not found")
}
} catch {
print("delete failed: \(error)")
}
也试试这个。
let mytable = Table("ContactTable")
let delRowCo = mytable.filter(ContactID == 'contact_id')
try db.run(delRowCo.delete())