javascript - Where to store SQLITE db file in electron production mode? - Stack Overflow

I'm building portable node js server using electron. I'm using SQLITE database for storing da

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

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

Share Improve this question asked Feb 19, 2021 at 20:35 HardRockHardRock 1,0912 gold badges17 silver badges43 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

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

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744896778a4599741.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信