swift-判断SQLite表是否存在

Github地址:SQLite.swift

    func tableExists() -> Bool{
        let result = try? db?.scalar("SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name = 'TableName'")
or /*
let result = try? db?.scalar("SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name = ? ","tableName")
*/
        let count = Int.fromDatatypeValue(result as! Int64) (刚学swift,我不晓得这里是不是这样用的,但测试没问题)
        return count == 1
    }

你可能感兴趣的:(swift-判断SQLite表是否存在)