简体   繁体   中英

Where to store SQLITE db file in electron production mode?

I'm building portable node js server using electron. 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 everything is running perfectly.

When I deploy my app electron-builder --mac and run it, it cannot access to database file. (File not found)

So my question is where should I store my test.db file so it's working both in development and production mode?

Is it possible to embed db file somewhere while creating application for win/mac/linux so end user doesn't need to take care where is db file located?

Thank you

you can store it into application data,
const dbPath = path.join(app.getPath("userData"), "sample.db")

Check out docs here, https://www.electronjs.org/docs/api/app#appgetpathname

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM