Reputation: 442
I have created an electron app, and built it with electron-builder. It creates a package in the dist folder, which I am able to install and then run the resulting application.
I have a sqlite database in the root folder of my project, with some data in it. But when I package and then run the exe file, it seems not to connect to the database or it appears empty. If I simply run the project with electron without packing, it is able to connect to the database and make use of the data.
Also, if visit the installation folder, there I find a copy of the database I had in my application but without any rows in it. Inside an .asar folder, there is a database populated as I would want but this one I supposedly cannot edit.
Would you have any pointers on what could be causing this? How can I properly connect to the database I have in the root folder of my project using sqlite, sequelize, windows and electron?
Thanks in advance
Upvotes: 1
Views: 1534
Reputation: 14847
electron-builder
doesn't pack the database file into the app ASAR (use the asarUnpack
option).app.getPath('userData')
and work with that copy. Your app generally does not have permission to write to the directory in which it is installed.Upvotes: 3