当前位置:网站首页>electron添加SQLite数据库
electron添加SQLite数据库
2022-07-07 09:09:00 【InfoQ】
序
electron
electron
SQLite
mongodb
pass
SQLite

- https://xie.infoq.cn/article/6c7094a919d33144f50cdc6d9《vue番茄钟&electron 打包》
- 《Node の MongoDB Driver》
- 《node の SQLite》
开发
sqliteDB.js
tomato.db
tomatoTable
runSQL(`
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
);
`)
ipcMain
ipcRenderer
sqlite
db.all
promise
// 查询番茄钟数据
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
边栏推荐
猜你喜欢
從色情直播到直播電商
The opacity value becomes 1%
Qtcreator sets multiple qmake
关于jmeter中编写shell脚本json的应用
“梦想杯”2017 年江苏省信息与未来小学生夏令营 IT 小能手 PK 之程序设计试题
Basic knowledge of process (orphan, zombie process)
How to use cherry pick?
seata 1.3.0 四种模式解决分布式事务(AT、TCC、SAGA、XA)
90后,辞职创业,说要卷死云数据库
【亲测可行】error while loading shared libraries的解决方案
随机推荐
[untitled]
Seata 1.3.0 four modes to solve distributed transactions (at, TCC, Saga, XA)
[machine learning 03] Lagrange multiplier method
【安装系统】U盘安装系统教程,使用UltraISO制作U盘启动盘
How to use cherry pick?
[pytorch 07] hands on deep learning chapter_ Preliminaries/ndarray exercises hands-on version
Wallhaven壁纸桌面版
Array object sorting
How to play video on unityui
2021-04-08
RationalDMIS2022 高级编程宏程序
IDEA快捷键大全
July 10, 2022 "five heart public welfare" activity notice + registration entry (two-dimensional code)
"Dream Cup" 2017 Jiangsu information and future primary school summer camp it expert PK program design questions
Process control (creation, termination, waiting, program replacement)
Deeply understand the characteristics of database transaction isolation
2021 summary and 2022 outlook
2022.7.6DAY598
uniCloud
测试开发基础,教你做一个完整功能的Web平台之环境准备