1

I'm trying to retrieve a count of records in a table using SQLite.swift and Swift in a Cocoa macOS application. All tables can try to get data from SQLite data only two tables is showing

no such table tablename (code:1)

My query for create table is

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)
})

My query to select table count

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

although the same code ,it is not working for one table. Anyone knows how to solve? Thanks Advance.

Chen Yin
  • 23
  • 5

0 Answers0