question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sqlite file in production

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
amilajackcommented, Oct 4, 2018

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.

5reactions
anupamvijayvergiacommented, Oct 12, 2018

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');

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found