Sqlite file in production
See original GitHub issueI’ve looked into #1410, #1316, #1115, and all issues in https://github.com/amilajack/erb-sqlite-example/, but I can’t seem to find the solution to package the app with a sqlite3 file.
This works in dev:
const dbPath = path.join(__dirname, 'db/database.db');
const db = new sqlite3.Database(dbPath);
I can read and write, but when packaging, I get Error: SQLITE_CANTOPEN: unable to open database file
. Because the file .db
file does not get packed into the final app. Any ideas?
Adding:
"extraFiles": [
"app/db/database.db"
]
in package.json
adds the file to Contents/app/db/database.db
when its packed, but I’m still unable to read it. Not sure what’s the best solution
thanks!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:7 (1 by maintainers)
Top Results From Across the Web
SQLite in production with WAL - victoria.dev
For certain applications, SQLite is a solid choice for a production database. It's lightweight, ultra-portable, and has no external dependencies ...
Read more >Appropriate Uses For SQLite
SQLite is often used as the on-disk file format for desktop applications such as version control systems, financial analysis tools, ...
Read more >Where to store SQLITE db file in electron production mode?
I'm using SQLITE database for storing data. In development mode I put database file test.db in directory where is my Main.js file and...
Read more >Production SQLite - Amazon S3
https://github.com/benbjohnson/production-sqlite-go ... Use time-based file naming format for multiple, rolling snapshots. • B-tree databases compress well.
Read more >Speeding up your development environment with SQLite
SQLite is a self-contained SQL database engine that significantly reduces the labor of setting up and maintaining databases in our ...
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
This is an ongoing issue with this boilerplate. I’m working to resolve this issue and am still experimenting. Will get back to you on this.
I’m using this and it works fine, Instead of packing database within the app, you can use as below.
const dbPath = (process.env.NODE_ENV === 'development') ? 'myDatabase.db' : path.resolve(app.getPath('userData'), 'myDatabase.db');