当前位置:网站首页>node の SQLite
node の SQLite
2022-07-06 17:48:00 【InfoQ】
node operation SQLite
mongodbSQLiteSQLiteinstall sqlite3 library
nodesqlite3yarn add sqlite3 -D
establish sqlite database
new sqlite3.Databasemongodbconst path = require('path');
const sqlite3 = require('sqlite3');
function SQLiteInit() {
let rootPath = path.join(__dirname, '../sqlite3.db');
let db = new sqlite3.Database(rootPath, (err)=>{
if (err) throw err;
console.log(' Database connection ')
})
}
Create a table and insert data
db.run// perform sql sentence
function runSQL(sqlstr) {
db.serialize(()=>{
db.run(sqlstr);
})
}let db = null;
function SQLiteInit() {
// Connect to database
let rootPath = path.join(__dirname, '../sqlite3.db');
db = new sqlite3.Database(rootPath)
// Create a table
runSQL(`
create table worker
(
name text not null,
age int not null,
hobby text not null
);
`)
// Close the connection
db.close();
}db.runpreparelet doc = [{
name: ' Zhang San ',
age: 18,
hobby: ' Hit Li Si ',
},
{
name: ' Li Si ',
age: 18,
hobby: ' Beat Wang Wu ',
},
{
name: ' Wang Wu ',
age: 18,
hobby: ' Open three ',
},
]
let insertInfo = db.prepare('insert into worker (name, age, hobby) values (?, ?, ?)')
doc.forEach((item)=>{
insertInfo.run(item.name, item.age, item.hobby);
})
insertInfo.finalize();vs code
Of
sqlite
plug-in unit
sqlitevs codesqlite
sqlite3.dbCtrl+Shift+PsqliteOpen Database
SQLITE EXPLORERsqlite3.dbNew Query
.sql-- SQLite
select * from worker

边栏推荐
- Selenium test of automatic answer runs directly in the browser, just like real users.
- 面试突击62:group by 有哪些注意事项?
- Spark calculation operator and some small details in liunx
- C # nanoframework lighting and key esp32
- Establishment of graphical monitoring grafana
- Pytorch extract middle layer features?
- MySQL advanced (index, view, stored procedure, function, password modification)
- 2021-03-22 "display login screen during recovery" can't be canceled. The appearance of lock screen interface leads to the solution that the remotely connected virtual machine can't work normally
- 03 products and promotion developed by individuals - plan service configurator v3.0
- Wechat applet obtains mobile number
猜你喜欢

Application service configurator (regular, database backup, file backup, remote backup)

EasyCVR授权到期页面无法登录,该如何解决?

sql语句优化,order by desc速度优化

中移动、蚂蚁、顺丰、兴盛优选技术专家,带你了解架构稳定性保障

自动化运维利器ansible基础

After entering Alibaba for the interview and returning with a salary of 35K, I summarized an interview question of Alibaba test engineer
![[introduction to MySQL] third, common data types in MySQL](/img/11/66b4908ed8f253d599942f35bde96a.png)
[introduction to MySQL] third, common data types in MySQL

Wordcloud colormap color set and custom colors

RepPoints:可形变卷积的进阶

Concept and basic knowledge of network layering
随机推荐
Pytorch extract middle layer features?
网络分层概念及基本知识
Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)
[ASM] introduction and use of bytecode operation classwriter class
Selenium test of automatic answer runs directly in the browser, just like real users.
10 advanced concepts that must be understood in learning SQL
MySQL advanced (index, view, stored procedure, function, password modification)
node の SQLite
scratch疫情隔离和核酸检测模拟 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月
The art of Engineering (1): try to package things that do not need to be exposed
Solid principle
The art of Engineering
78 岁华科教授逐梦 40 载,国产数据库达梦冲刺 IPO
EasyCVR授权到期页面无法登录,该如何解决?
Vscode matches and replaces the brackets
TCP connection is more than communicating with TCP protocol
微信小程序获取手机号
Sqoop I have everything you want
Unity小技巧 - 绘制瞄准准心
SAP UI5 框架的 manifest.json