Saturday, October 27, 2018

Swift : How to Drop a table?

Below is the code to do that

open func dropTable(tableName:String) -> Bool{
        let opened = openDatabase();
        if(!opened){
            return false
        }
        let query = "DROP TABLE IF EXISTS "+tableName
        if(sqlite3_exec(db,query,nil,nil,nil) != SQLITE_OK){
            let errMsg = String(cString:sqlite3_errmsg(db!))
            if errMsg.count > 0 {
                return false
            }
        }
        return true
    }

references:

No comments:

Post a Comment