sqlite3 db-file is not found within app.asar
See original GitHub issuehappy easter,
Trying to create a build for mac osx, also working on a mac. This is a part of my package.json to show what i use (based on electron-boilerplate-sqlite):
"dependencies": {
"sqlite3": "^3.1.8"
},
"devDependencies": {
"electron": "^1.6.2",
"electron-builder": "^10.17.3"
}
This is how i set the path to the db-file const dbFile = path.join(__dirname, ‘/appData.db’);
In the build the path is like this: /Users/[USERNAME]/[PATH-TO-CONTENT]/Contents/Resources/app.asar/app/appData.db
… and I end up with an error: SQLITE_CANTOPEN: unable to open database file
Now setting asar to false in the build-options. The path is now like this: /Users/[USERNAME]/[PATH-TO-CONTENT]/Contents/Resources/app/app/appData.db
The app works fine. How can i solve this problem?
regards, jo
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
sqlite3 db file not created immediately after app installation ...
I`m creating an windows app using React and Electron JS with database file using sqlite3. Im saving the database file in the '/databases' ......
Read more >DB file sqlite not found
What happened here is that the package built a database and stored it in the file cache, but then that database was wiped...
Read more >How do I access a Sqlite3 database from an Electron ... - Reddit
I am currently writing an application using Electron and BetterSqlite. I build the AppImage like this: npm run build && electron-builder build.
Read more >errno: 14, code: 'sqlite_cantopen' - You.com | The AI Search ...
I have this Electron app that uses a SQLite Database. So first it checks if database exist on the appData folder (I'm on...
Read more >[Fixed]-Anonymise SQLite database? - appsloveworld.com
Featured post · In your application, hold the fake names in two arrays - one for male and one for female. · Do...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
thanks for the hint, but it seems to be not very handy… i end up here:
"extraResources": ["appData.db"],
and here:
const dbFile = path.join(__dirname, ‘/appData.db’).replace(‘/app.asar’, ‘’);
hmmm…
hi evryone i fix it with this in packege.json , in build section add: “extraResources”: [ “path/to/database.sqlite3” ], in main.js add use: const getDBPath = (filename) => { let base = app.getAppPath() if (app.isPackaged) { base = base.replace(‘\app.asar’, ‘’) } return path.resolve(base,
path/to/${filename}.sqlite3
) }