当前位置:网站首页>node. JS connecting sqlserver encapsulating MSSQL
node. JS connecting sqlserver encapsulating MSSQL
2022-06-09 22:03:00 【Old man,】
npm i mssql
mssql edition 8.1.1
db.js encapsulation
var sql = require('mssql');
var dbConfig = {
user: 'sa',
password: '1111',
server: '111.111.111.111',
database: 'db_text',
port: 1433,
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000
},
options:{
encrypt: false
}
};
function getAllUsers(sqls) {
return new Promise((resolve,reject)=>{
var conn = new sql.ConnectionPool(dbConfig);
var req = new sql.Request(conn);
conn.connect(function (err) {
if (err) {
console.log(err);
resolve([err])
// return;
}
req.query(sqls, function (err, recordset) {
// if (err) {
// console.log(err);
// return;
// }
// else {
// console.log(recordset);
// }
conn.close();
resolve([err,recordset])
});
});
})
}
module.exports=getAllUsers;
index.js quote
var db = require('./db');
async function asa(){
let sql = `select * from tb_userinfo`;
let [err,recordset]=await db(sql)
console.log(recordset,'aaa');
}
asa()
var express=require('express')
var app=express()
app.listen(3000,()=>{
console.log(' Service is turned on ')});
var db = require('./db');
app.get('/index',async (req,res)=>{
let sql = `select * from tb_userinfo`;
let [err,recordset]=await db(sql)
console.log(recordset,'aaa');
res.send('asas')
})
边栏推荐
- SPI communication principle +verilog implementation and simulation (complete code)
- LiDAR相关介绍
- spider pi 智能视觉六足机器人 标签识别 ApirlTag标签 0604
- spider pi 智能視覺六足機器人 vnc連接機器人 0603
- Database SQL and Gorm practice of design pattern | notes on youth training camp
- Thoughts on "sword finger offer1-32"
- Unity get the content information of XML file
- The 14th Sudoku - true standard Sudoku -day 6-20220121 (supplementary)
- mysql中如何修改字段的enum枚举类型值
- 与鲲鹏代码迁移工具的初次邂逅
猜你喜欢

每日技术分享之EIGRP的负载均衡配置

Basic use of DataGridView 0526

swagger上的model和返回的数据字段不一致的问题

JS cast and implicit type conversion and Unicode encoding

How to make our self built site have a custom domain name (1)
![Acitivit's mental journey: activiti6.0 customizes any jump command [including rollback]](/img/5f/97852ac7279fccdeff55c445344cbc.png)
Acitivit's mental journey: activiti6.0 customizes any jump command [including rollback]

TL, how do you manage project risks?
![【代码审计】buu_[GWCTF 2019]mypassword](/img/fc/f342cb8987b779d317519d0c1b9ed4.png)
【代码审计】buu_[GWCTF 2019]mypassword

Online salon | open source show -- Application Practice of database technology
![Express order information extraction [3] - five labeled data to improve accuracy. Only five labeled samples are required to quickly complete the express order information task](/img/fd/3e71ba9ec37f71982714b8a233a788.png)
Express order information extraction [3] - five labeled data to improve accuracy. Only five labeled samples are required to quickly complete the express order information task
随机推荐
Design and Simulation of SD card reading and writing based on FPGA Verilog
[playing with Huawei cloud] actual combat of tag recognition based on Huawei cloud image
【luogu P8330】众数(根号分治)
校园锐捷路由器使用指南
An RS485 serial interface current sensor snap on type mutual inductor supports Modbus communication protocol
Beautify aria theme to rival charging theme mirages
202206007 模拟赛 总结
es5中构造函数的属性继承 借用父构造函数 方法继承 原型对象
YOLO系列目标检测后处理-非极大值抑制
数据库每日一题---第7天:订单最多的客户
Deploy MySQL based on statefulset in kubernetes (Part 2)
Modbus protocol and serialport port read / write
spider pi 智能视觉六足机器人 标签识别 ApirlTag标签 0604
Express order information extraction [3] - five labeled data to improve accuracy. Only five labeled samples are required to quickly complete the express order information task
易买网开发 趣买买 数据库的导入与数据库结构一览表 0605
易买网开发 趣买买 项目资源一览 0605
How to locate the cause of high CPU on the server
[flow analysis] Buu_ [an Xun cup 2019]attack
sqlserver2012 不允许修改表结构的问题解决 0607
Introduction to startup of spider PI intelligent vision hexapod robot 0602