I'm using a sqlite database called sqlite.db
in my app.
The database is located in the top directory of my app.
I test the app with npm start
while developing. While testing, the database works fine.
After creating the app via npm run make
(electron-forge), the database cannot be accessed with the following error: SQLITE_CANTOPEN: unable to open database file with electron-forge
.
- My first thought was a wrong directory in the code, but that doesn't seem to be the issue after all.
- Also the database itself is available in the packed application.
- And it doesn't seem to be a code issue as texting works fine:
const sqlite3 = require('sqlite3');
const { open } = require('sqlite');
sqlite3.verbose();
return open({
filename, //filename='./sqlite.db' (actually a path)
driver: sqlite3.Database
});
This brings me to the conclusion, something must be wrong in the configuration for the app-building process via Electron Forge. But I have no clue if that assumption is correct - and if so, how to do that.
The closest I found to a fix was this similar issue but with Electron Builder - since I use Electron Forge, I wasn't able to apply the suggested solution 1:1...