美文网首页
swift-判断SQLite表(name)是否存在

swift-判断SQLite表(name)是否存在

作者: HappyJiuOk | 来源:发表于2020-01-02 09:33 被阅读0次

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表(name)是否存在

      本文链接:https://www.haomeiwen.com/subject/psunoctx.html