mssql node js documentation
const sql = require('mssql') const sqlConfig = { user: process.env.DB_USER, password: process.env.DB_PWD, database: process.env.DB_NAME, server: 'localhost', pool: { max: 10, min: 0, idleTimeoutMillis: 30000 }, options: { encrypt: true, // for azure trustServerCertificate: false // change to true for local dev / self-signed certs } } async () => { try { // make sure that any items are correctly URL encoded in the connection string await sql.connect(sqlConfig) const result = await sql.query`select * from mytable where id = ${value}` console.dir(result) } catch (err) { // ... error checks } }
Source: www.npmjs.com
node mssql
Installation npm install mssql Short Example: Use Connect String const sql = require('mssql') async () => { try { // make sure that any items are correctly URL encoded in the connection string await sql.connect('Server=localhost,1433;Database=database;User Id=username;Password=password;Encrypt=true') const result = await sql.query`select * from mytable where id = ${value}` console.dir(result) } catch (err) { // ... error checks } }
Source: github.com