当前位置:网站首页>electron添加SQLite数据库
electron添加SQLite数据库
2022-07-07 09:09:00 【InfoQ】
序
electronelectronSQLitemongodbpassSQLite
- https://xie.infoq.cn/article/6c7094a919d33144f50cdc6d9《vue番茄钟&electron 打包》
- 《Node の MongoDB Driver》
- 《node の SQLite》
开发
sqliteDB.jstomato.dbtomatoTablerunSQL(`
create table tomatoTable
(
name text not null,
creatTime text not null,
duringTime int not null,
startFlag boolean not null,
bgSrc text not null,
taskEndCount int not null,
taskId text not null
);
`)ipcMainipcRenderersqlitedb.allpromise// 查询番茄钟数据
function getTomatoData() {
db = new sqlite3.Database(rootPath);
return new Promise((reslove)=>{
db.all('select * from tomatoTable', (err, data)=>{
reslove(data);
});
})
}
JSON.parse
// 向番茄钟表插入新数据
function insertNewInfo(d) {
let insertInfo = db.prepare('insert into tomatoTable (name, creatTime, duringTime, startFlag, bgSrc, taskEndCount, taskId) values (?, ?, ?, ?, ?, ?, ?)')
insertInfo.run(d.name, d.creatTime, d.duringTime, d.startFlag, d.bgSrc, d.taskEndCount, d.taskId );
insertInfo.finalize();
}
// 从番茄钟表删除数据
function deleteNewInfo(taskId) {
let del = db.prepare("delete from tomatoTable where taskId = ? ");
del.run(taskId);
del.finalize();
}
// 修改番茄钟任务完成次数
function updateTaskEndCount(arg) {
let update = db.prepare('update tomatoTable set taskEndCount = ? where taskId = ?');
update.run(arg.taskEndCount, arg.taskId);
update.finalize();
}
-- SQLite
select * from tomatoTable

tomato.db边栏推荐
- 关于jmeter中编写shell脚本json的应用
- 滚动踩坑--UNI_APP(八)
- Bookmarking - common website navigation for programmers
- The eighth training assignment
- 数据库同步工具 DBSync 新增对MongoDB、ES的支持
- Typescript interface inheritance
- Poj1821 fence problem solving Report
- [pytorch 07] hands on deep learning chapter_ Preliminaries/ndarray exercises hands-on version
- uniapp 在onLaunch中跳转页面后,点击事件失效解决方法
- 高考作文,高频提及科技那些事儿……
猜你喜欢
随机推荐
在我有限的软件测试经历里,一段专职的自动化测试经验总结
The eighth training assignment
vim 的各种用法,很实用哦,都是本人是在工作中学习和总结的
V-for img SRC rendering fails
Compile QT project script with qmake
Go redis Middleware
Arduino receives and sends strings
How to use cherry pick?
书签整理-程序员常用网站导航
Hash / (understanding, implementation and application)
RationalDMIS2022 高级编程宏程序
單調性約束與反單調性約束的區別 monotonicity and anti-monotonicity constraint
Galaxy Kirin desktop operating system installation postgresql13 (source code installation)
oracle常见锁表处理方式
Still cannot find RPC dispatcher table failed to connect in virtual KD
Interprocess communication (IPC)
Which securities company is the best and safest to open an account for the subscription of new shares
[untitled]
使用引用
uniCloud
![[untitled]](/img/f0/a34c116a793e844da46c7cd407224b.jpg)

![[untitled]](/img/a0/29975bc0f9832e1640cc39dfce4a71.jpg)
![[C #] the solution of WinForm operation zoom (blur)](/img/66/b70213c95acd4ad9fe2eb739bd46b5.png)


![[OneNote] can't connect to the network and can't sync the problem](/img/28/9a02b1da0f43889989a9539c9fb6b6.png)

![[untitled]](/img/c2/d70d052b7e9587dc81c622f62f8566.jpg)
