网友回复
electron支持sqlite,安装方法:
在 package.json添加postinstall "scripts": { "postinstall": "install-app-deps" ... }
然后安装依赖
npm install --save-dev electron-builder
npm install --save sqlite3
npm run postinstall
操作sqlite代码
import sq3 from "sqlite3"; const sqlite3 = sq3.verbose() const db = new sqlite3.Database('sq3.db') db.serialize(() => { db.run("create table test(name varchar(20))", () => { db.run("insert into test values('nihao')", () => { db.all("select * from test", (err, res) => { if (err) throw err console.log(JSON.stringify(res)) }) }) }) }) export default db