Reputation: 23
I use path obtained from Bundle.main.path can not insert update sqlite database with db.execute function No display error, I do not understand why, please help me below is my code
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!)")
Upvotes: 0
Views: 71
Reputation: 262
You can not write into a file within the app bundle, you have to copy the sqlite file to e.g. the documents directory and use that copy to save your data.
Upvotes: 1