Reputation: 21
I have created a build using electron and npm. The application is using sqlite as a database. The application is ruuning great before creating the build(npm run build). But after creating the build the database become redonly. I have checked the permission by command "ls -asl" but it is showing read/write both the permission to the database file. But when I am trying to insert/update any records is throwing the error "Error: SQLITE_READONLY: Attempt to write a readonly database". I don't know why this is happning. Please provide some help here.
Upvotes: 1
Views: 1180
Reputation: 192
The folder the database resides in must have write permissions, as well as the actual database file.
In my case, I had my sqlite file inside database folder as below
database (Initial permission 665)
- app.db (Initial permission 665)
changed above permission as
database (Initial permission 667)
- app.db (Initial permission 666)
Upvotes: 0
Reputation: 14847
Don't put the database file inside the application installation directory, put it in the directory returned by app.getPath('userData')
instead.
Upvotes: 3