-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (31 loc) · 808 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const dotenv = require('dotenv')
dotenv.config({ silent: true })
const sql = require('mssql')
const config = {
user: process.env.USER,
password: process.env.PASSWORD,
server: process.env.SERVER,
database: DATABASE,
options: {
enableArithAbort: true,
},
}
console.group('Start')
console.log('========================================================')
const run = async () => {
let pool
try {
console.log('Connection Opening...')
pool = await sql.connect(config)
const { recordset } = await sql.query`select * from users`
console.log({ recordset })
} catch (err) {
console.log({ err })
} finally {
await pool.close
console.log('connection Closed')
}
}
run()
console.group('END')
console.log('========================================================')