【发布时间】:2020-08-05 00:12:17
【问题描述】:
我当前的代码是用 Swift 3 编写的,我尝试通过 Xcode10.1 更改 Swift 4.2。 SQLite 在更改版本时崩溃并且在旧代码上正常工作。
我正在尝试在 Cocoa macOS 应用程序中使用 SQLite.swift 和 Swift 检索表中的记录计数。
let db = try Connection("\(pathh)/db.sqlite3")
let users = Table("users")
var count = try db.scalar(users.filter(userid == userid).count)
但是,当执行这段代码时,会抛出以下异常:
unrecognized token: ":" (code: 1)
当我尝试使用 var count = try db.scalar("SELECT COUNT(*) FROM users WHERE userid=?",userid) as! Int64 时,会返回正确的结果。
但是这个usu-age返回错误
no such table tablename (code:1)
对于一些表。
我们将不胜感激。提前致谢!
【问题讨论】:
标签: ios xcode swift4.2 sqlite.swift xcode11.4