如何访问现有的数据库文件

时间:2018-10-26 18:29:33

标签: ios swift

我尝试访问但使用此方法却收到错误消息“找不到这样的表”

let path =  try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false).appendingPathComponent("NewFile.db")

let database = FMDatabase(path: path.path)
if !database.open() {
    print("Unable to open database")
    return
}

    if let rs = database.executeQuery(" SELECT * FROM myowntable", withArgumentsIn: []) {
      while rs.next() {
        //...

      }
    } else {
      print("executeQuery failed: \(database.lastErrorMessage())")
    }


    database.close()

0 个答案:

没有答案