我当前的代码是用 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
时,会返回正确的结果。
任何和所有的帮助将不胜感激。提前致谢!