0

我想在 SQLite.Swift 中删除具有给定值 ( contactID) 的行,这也是主键:

let delRowCo = ContactTable.filter(ContactID == contactID) try db.run(delRowCo.delete())

给定的contactID肯定存在,但它不会删除该行...

4

2 回答 2

1

尝试一些错误处理。如果有任何错误,您会发现。

do {
   if try db.run(delRowCo.delete()) > 0 {
       print("deleted")
   } else {
       print("row not found")
   }
} catch {
    print("delete failed: \(error)")
}
于 2015-12-17T17:55:14.903 回答
0

也试试这个。

let mytable = Table("ContactTable")
let delRowCo = mytable.filter(ContactID == 'contact_id')
try db.run(delRowCo.delete())
于 2015-12-17T17:58:33.043 回答