swift 3:db.cecute不使用get路径运行使用bundle.main.path



i使用从bundle.main.path无法插入db.ececute函数的路径。没有显示错误,我不明白为什么,请帮助我以下是我的代码

var config = Configuration()
config.readonly = false
config.foreignKeysEnabled = false
enter code here
let path1:String = Bundle.main.path(forResource: "data", ofType: "sqlite",inDirectory: "Data")!
db = try DatabaseQueue(path: path1,configuration:  config)
--------------
try db.execute("update detail set favorite = (newDetail.favorite!) where id = (newDetail.id!)")

您无法在应用程序包中的文件中写入文件,必须将SQLite文件复制到例如。文档目录并使用该副本保存您的数据。

最新更新