1

我正在尝试在 Cocoa macOS 应用程序中使用 SQLite.swift 和 Swift 检索表中的记录数。所有表都可以尝试从 SQLite 数据中获取数据,只有两个表显示

no such table tablename (code:1)

我对创建表的查询是

try db.run(table1.create(ifNotExists: true) {t in 
t.column(c1,primaryKey: true)
t.column(c2)
})
try db.run(table2.create(ifNotExists: true) {t in 
t.column(c1,primaryKey: true)
t.column(c2)
})

我的查询选择表数

var count = try db.scalar("SELECT COUNT(*) FROM table1 WHERE userid=?",userid) as! Int64
var count = try db.scalar("SELECT COUNT(*) FROM table2 WHERE userid=?",userid) as! Int64

尽管代码相同,但它不适用于一张桌子。有谁知道如何解决?谢谢提前。

4

0 回答 0