forked from TimelordUK/node-sqlserver-v8
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple-pool.js
More file actions
executable file
·34 lines (28 loc) · 761 Bytes
/
simple-pool.js
File metadata and controls
executable file
·34 lines (28 loc) · 761 Bytes
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
const { TestEnv } = require('../../test/env/test-env')
const env = new TestEnv()
const connectionString = env.connectionString
process.on('uncaughtException', err => {
console.error('There was an uncaught error', err)
process.exit(1) // mandatory (as per the Node.js docs)
})
async function run (iterations) {
const pool = new env.sql.Pool({
connectionString
})
pool.on('error', err => {
console.error('pool error was an uncaught error', err)
})
await pool.promises.open()
const testSql = 'select a;'
for (let i = 0; i < iterations; ++i) {
try {
await pool.promises.query(testSql)
} catch (e) {
console.error('error', e)
}
}
await pool.promises.close()
}
run(4).then(() => {
console.log('exit.')
})