mssql 7.2.1 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.txt +10 -0
- package/LICENSE.md +22 -22
- package/README.md +7 -3
- package/bin/mssql +0 -0
- package/lib/base/prepared-statement.js +4 -0
- package/lib/base/request.js +13 -11
- package/lib/base/transaction.js +4 -0
- package/lib/cli.js +113 -113
- package/lib/isolationlevel.js +9 -9
- package/package.json +2 -2
- package/test.js +40 -47
package/CHANGELOG.txt
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
v7.3.0 (2021-11-18)
|
|
2
|
+
-------------------
|
|
3
|
+
[new] Transaction/PreparedStatements expose the config from their parent connection
|
|
4
|
+
[fix] Fix inherited request configs from the pool. Specifically stream and arrayRowMode now inherit accurately from the connection config ([#1338](https://github.com/tediousjs/node-mssql/pull/1338))
|
|
5
|
+
|
|
1
6
|
v7.2.1 (2021-08-19)
|
|
2
7
|
-------------------
|
|
3
8
|
[fix] Fix issue with bulk insert of dates ((#1298)[https://github.com/tediousjs/node-mssql/pull/1298])
|
|
@@ -44,6 +49,11 @@ v7.0.0 (2021-05-06)
|
|
|
44
49
|
[fix] Connection config objects are now deep cloned when stored against a connection pool ([#1217](https://github.com/tediousjs/node-mssql/pull/1217))
|
|
45
50
|
[removed] Support for connection uri format has been removed (eg: `mssql://user:password@host/?params=values`)
|
|
46
51
|
|
|
52
|
+
v6.4.0 (2021-11-18)
|
|
53
|
+
-------------------
|
|
54
|
+
[new] Transaction/PreparedStatements expose the config from their parent connection
|
|
55
|
+
[fix] Fix inherited request configs from the pool. Specifically stream and arrayRowMode now inherit accurately from the connection config ([#1338](https://github.com/tediousjs/node-mssql/pull/1338))
|
|
56
|
+
|
|
47
57
|
v6.3.2 (2021-05-13)
|
|
48
58
|
-------------------
|
|
49
59
|
[fix] Bump various dependencies for security fixes
|
package/LICENSE.md
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013-2018 Patrik Simek and contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
22
|
-
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013-2018 Patrik Simek and contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
CHANGED
|
@@ -140,7 +140,7 @@ async () => {
|
|
|
140
140
|
* [SQL injection](#sql-injection)
|
|
141
141
|
* [Known Issues](#known-issues)
|
|
142
142
|
* [Contributing](https://github.com/tediousjs/node-mssql/wiki/Contributing)
|
|
143
|
-
* [6.x to 7.x changes
|
|
143
|
+
* [6.x to 7.x changes](#6x-to-7x-changes)
|
|
144
144
|
* [5.x to 6.x changes](#5x-to-6x-changes)
|
|
145
145
|
* [4.x to 5.x changes](#4x-to-5x-changes)
|
|
146
146
|
* [3.x to 4.x changes](#3x-to-4x-changes)
|
|
@@ -2094,11 +2094,15 @@ request.query('select @myval as myval', (err, result) => {
|
|
|
2094
2094
|
- If you're facing problems with connecting SQL Server 2000, try setting the default TDS version to 7.1 with `config.options.tdsVersion = '7_1'` ([issue](https://github.com/tediousjs/node-mssql/issues/36))
|
|
2095
2095
|
- If you're executing a statement longer than 4000 chars on SQL Server 2000, always use [batch](#batch-batch-callback) instead of [query](#query-command-callback) ([issue](https://github.com/tediousjs/node-mssql/issues/68))
|
|
2096
2096
|
|
|
2097
|
-
## 6.x to 7.x changes
|
|
2097
|
+
## 6.x to 7.x changes
|
|
2098
2098
|
|
|
2099
|
-
- Upgraded tedious version to
|
|
2099
|
+
- Upgraded tedious version to v11
|
|
2100
|
+
- Upgraded msnodesqlv8 version support to v2
|
|
2101
|
+
- Upgraded tarn.js version to v3
|
|
2100
2102
|
- Requests in stream mode that pipe into other streams no longer pass errors up the stream chain
|
|
2103
|
+
- Request.pipe now pipes a true node stream for better support of backpressure
|
|
2101
2104
|
- tedious config option `trustServerCertificate` defaults to `false` if not supplied
|
|
2105
|
+
- Dropped support for Node < 10
|
|
2102
2106
|
|
|
2103
2107
|
## 5.x to 6.x changes
|
|
2104
2108
|
|
package/bin/mssql
CHANGED
|
File without changes
|
package/lib/base/request.js
CHANGED
|
@@ -26,7 +26,7 @@ class Request extends EventEmitter {
|
|
|
26
26
|
/**
|
|
27
27
|
* Create new Request.
|
|
28
28
|
*
|
|
29
|
-
* @param {Connection|ConnectionPool|Transaction|PreparedStatement} parent If
|
|
29
|
+
* @param {Connection|ConnectionPool|Transaction|PreparedStatement} parent If omitted, global connection is used instead.
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
constructor (parent) {
|
|
@@ -39,6 +39,8 @@ class Request extends EventEmitter {
|
|
|
39
39
|
this._paused = false
|
|
40
40
|
this.parent = parent || globalConnection.pool
|
|
41
41
|
this.parameters = {}
|
|
42
|
+
this.stream = null
|
|
43
|
+
this.arrayRowMode = null
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
get paused () {
|
|
@@ -224,8 +226,8 @@ class Request extends EventEmitter {
|
|
|
224
226
|
*/
|
|
225
227
|
|
|
226
228
|
batch (batch, callback) {
|
|
227
|
-
if (this.stream
|
|
228
|
-
if (this.arrayRowMode
|
|
229
|
+
if (this.stream === null && this.parent) this.stream = this.parent.config.stream
|
|
230
|
+
if (this.arrayRowMode === null && this.parent) this.arrayRowMode = this.parent.config.arrayRowMode
|
|
229
231
|
this.rowsAffected = 0
|
|
230
232
|
|
|
231
233
|
if (typeof callback === 'function') {
|
|
@@ -288,11 +290,11 @@ class Request extends EventEmitter {
|
|
|
288
290
|
*/
|
|
289
291
|
|
|
290
292
|
_batch (batch, callback) {
|
|
291
|
-
if (!this.
|
|
293
|
+
if (!this.parent) {
|
|
292
294
|
return setImmediate(callback, new RequestError('No connection is specified for that request.', 'ENOCONN'))
|
|
293
295
|
}
|
|
294
296
|
|
|
295
|
-
if (!this.
|
|
297
|
+
if (!this.parent.connected) {
|
|
296
298
|
return setImmediate(callback, new ConnectionError('Connection is closed.', 'ECONNCLOSED'))
|
|
297
299
|
}
|
|
298
300
|
|
|
@@ -317,8 +319,8 @@ class Request extends EventEmitter {
|
|
|
317
319
|
options = {}
|
|
318
320
|
}
|
|
319
321
|
|
|
320
|
-
if (this.stream
|
|
321
|
-
if (this.arrayRowMode
|
|
322
|
+
if (this.stream === null && this.parent) this.stream = this.parent.config.stream
|
|
323
|
+
if (this.arrayRowMode === null && this.parent) this.arrayRowMode = this.parent.config.arrayRowMode
|
|
322
324
|
|
|
323
325
|
if (this.stream || typeof callback === 'function') {
|
|
324
326
|
this._bulk(table, options, (err, rowsAffected) => {
|
|
@@ -419,8 +421,8 @@ class Request extends EventEmitter {
|
|
|
419
421
|
*/
|
|
420
422
|
|
|
421
423
|
query (command, callback) {
|
|
422
|
-
if (this.stream
|
|
423
|
-
if (this.arrayRowMode
|
|
424
|
+
if (this.stream === null && this.parent) this.stream = this.parent.config.stream
|
|
425
|
+
if (this.arrayRowMode === null && this.parent) this.arrayRowMode = this.parent.config.arrayRowMode
|
|
424
426
|
this.rowsAffected = 0
|
|
425
427
|
|
|
426
428
|
if (typeof callback === 'function') {
|
|
@@ -508,8 +510,8 @@ class Request extends EventEmitter {
|
|
|
508
510
|
*/
|
|
509
511
|
|
|
510
512
|
execute (command, callback) {
|
|
511
|
-
if (this.stream
|
|
512
|
-
if (this.arrayRowMode
|
|
513
|
+
if (this.stream === null && this.parent) this.stream = this.parent.config.stream
|
|
514
|
+
if (this.arrayRowMode === null && this.parent) this.arrayRowMode = this.parent.config.arrayRowMode
|
|
513
515
|
this.rowsAffected = 0
|
|
514
516
|
|
|
515
517
|
if (typeof callback === 'function') {
|
package/lib/base/transaction.js
CHANGED
package/lib/cli.js
CHANGED
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const path = require('path')
|
|
5
|
-
const sql = require('./tedious')
|
|
6
|
-
|
|
7
|
-
const exit = process.exit
|
|
8
|
-
const write = text => process.stdout.write(text)
|
|
9
|
-
Buffer.prototype.toJSON = () => {
|
|
10
|
-
return `0x${this.toString('hex')}`
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Resolve config path
|
|
14
|
-
|
|
15
|
-
let cfgPath = path.resolve(process.argv[2] || process.cwd())
|
|
16
|
-
if (fs.lstatSync(cfgPath).isDirectory()) {
|
|
17
|
-
cfgPath = path.resolve(cfgPath, './.mssql.json')
|
|
18
|
-
}
|
|
19
|
-
if (!fs.existsSync(cfgPath)) {
|
|
20
|
-
console.error('Config file not found.')
|
|
21
|
-
exit(1)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Config checks & parse
|
|
25
|
-
|
|
26
|
-
let config
|
|
27
|
-
try {
|
|
28
|
-
config = fs.readFileSync(cfgPath)
|
|
29
|
-
} catch (err) {
|
|
30
|
-
console.error(`Failed to load config file. ${err.message}`)
|
|
31
|
-
exit(1)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
config = JSON.parse(config)
|
|
36
|
-
} catch (err) {
|
|
37
|
-
console.error(`Failed to parse config file. ${err.message}`)
|
|
38
|
-
exit(1)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Read stdin
|
|
42
|
-
|
|
43
|
-
const buffer = []
|
|
44
|
-
|
|
45
|
-
process.stdin.setEncoding('utf8')
|
|
46
|
-
process.stdin.on('readable', () => buffer.push(process.stdin.read()))
|
|
47
|
-
|
|
48
|
-
process.stdin.on('end', () => {
|
|
49
|
-
const statement = buffer.join('')
|
|
50
|
-
let rst = 0
|
|
51
|
-
let index = 0
|
|
52
|
-
|
|
53
|
-
if (!statement.length) {
|
|
54
|
-
console.error('Statement is empty.')
|
|
55
|
-
exit(1)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
sql.connect(config, err => {
|
|
59
|
-
if (err) {
|
|
60
|
-
console.error(err.message)
|
|
61
|
-
exit(1)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
write('[')
|
|
65
|
-
|
|
66
|
-
const request = new sql.Request()
|
|
67
|
-
request.stream = true
|
|
68
|
-
request.on('recordset', () => {
|
|
69
|
-
index = 0
|
|
70
|
-
if (rst++ > 0) {
|
|
71
|
-
write('],')
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return write('[')
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
request.on('error', err => {
|
|
78
|
-
console.error(err.message)
|
|
79
|
-
sql.close()
|
|
80
|
-
return exit(1)
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
request.on('row', row => {
|
|
84
|
-
if (index++ > 0) {
|
|
85
|
-
write(',')
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return write(JSON.stringify(row))
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
request.on('done', () => {
|
|
92
|
-
if (rst > 0) {
|
|
93
|
-
write(']')
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
write(']\n')
|
|
97
|
-
sql.close()
|
|
98
|
-
return exit(0)
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
request.query(statement)
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
process.on('uncaughtException', err => {
|
|
106
|
-
if (err.code === 'EPIPE') {
|
|
107
|
-
console.error('Failed to pipe output stream.')
|
|
108
|
-
} else {
|
|
109
|
-
console.error(err.message)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
exit(1)
|
|
113
|
-
})
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const fs = require('fs')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const sql = require('./tedious')
|
|
6
|
+
|
|
7
|
+
const exit = process.exit
|
|
8
|
+
const write = text => process.stdout.write(text)
|
|
9
|
+
Buffer.prototype.toJSON = () => {
|
|
10
|
+
return `0x${this.toString('hex')}`
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Resolve config path
|
|
14
|
+
|
|
15
|
+
let cfgPath = path.resolve(process.argv[2] || process.cwd())
|
|
16
|
+
if (fs.lstatSync(cfgPath).isDirectory()) {
|
|
17
|
+
cfgPath = path.resolve(cfgPath, './.mssql.json')
|
|
18
|
+
}
|
|
19
|
+
if (!fs.existsSync(cfgPath)) {
|
|
20
|
+
console.error('Config file not found.')
|
|
21
|
+
exit(1)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Config checks & parse
|
|
25
|
+
|
|
26
|
+
let config
|
|
27
|
+
try {
|
|
28
|
+
config = fs.readFileSync(cfgPath)
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.error(`Failed to load config file. ${err.message}`)
|
|
31
|
+
exit(1)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
config = JSON.parse(config)
|
|
36
|
+
} catch (err) {
|
|
37
|
+
console.error(`Failed to parse config file. ${err.message}`)
|
|
38
|
+
exit(1)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Read stdin
|
|
42
|
+
|
|
43
|
+
const buffer = []
|
|
44
|
+
|
|
45
|
+
process.stdin.setEncoding('utf8')
|
|
46
|
+
process.stdin.on('readable', () => buffer.push(process.stdin.read()))
|
|
47
|
+
|
|
48
|
+
process.stdin.on('end', () => {
|
|
49
|
+
const statement = buffer.join('')
|
|
50
|
+
let rst = 0
|
|
51
|
+
let index = 0
|
|
52
|
+
|
|
53
|
+
if (!statement.length) {
|
|
54
|
+
console.error('Statement is empty.')
|
|
55
|
+
exit(1)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
sql.connect(config, err => {
|
|
59
|
+
if (err) {
|
|
60
|
+
console.error(err.message)
|
|
61
|
+
exit(1)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
write('[')
|
|
65
|
+
|
|
66
|
+
const request = new sql.Request()
|
|
67
|
+
request.stream = true
|
|
68
|
+
request.on('recordset', () => {
|
|
69
|
+
index = 0
|
|
70
|
+
if (rst++ > 0) {
|
|
71
|
+
write('],')
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return write('[')
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
request.on('error', err => {
|
|
78
|
+
console.error(err.message)
|
|
79
|
+
sql.close()
|
|
80
|
+
return exit(1)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
request.on('row', row => {
|
|
84
|
+
if (index++ > 0) {
|
|
85
|
+
write(',')
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return write(JSON.stringify(row))
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
request.on('done', () => {
|
|
92
|
+
if (rst > 0) {
|
|
93
|
+
write(']')
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
write(']\n')
|
|
97
|
+
sql.close()
|
|
98
|
+
return exit(0)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
request.query(statement)
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
process.on('uncaughtException', err => {
|
|
106
|
+
if (err.code === 'EPIPE') {
|
|
107
|
+
console.error('Failed to pipe output stream.')
|
|
108
|
+
} else {
|
|
109
|
+
console.error(err.message)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
exit(1)
|
|
113
|
+
})
|
package/lib/isolationlevel.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
READ_UNCOMMITTED: 0x01,
|
|
5
|
-
READ_COMMITTED: 0x02,
|
|
6
|
-
REPEATABLE_READ: 0x03,
|
|
7
|
-
SERIALIZABLE: 0x04,
|
|
8
|
-
SNAPSHOT: 0x05
|
|
9
|
-
}
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
READ_UNCOMMITTED: 0x01,
|
|
5
|
+
READ_COMMITTED: 0x02,
|
|
6
|
+
REPEATABLE_READ: 0x03,
|
|
7
|
+
SERIALIZABLE: 0x04,
|
|
8
|
+
SNAPSHOT: 0x05
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"azure",
|
|
22
22
|
"node-mssql"
|
|
23
23
|
],
|
|
24
|
-
"version": "7.
|
|
24
|
+
"version": "7.3.0",
|
|
25
25
|
"main": "index.js",
|
|
26
26
|
"repository": "github:tediousjs/node-mssql",
|
|
27
27
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"mocha": "^8.4.0",
|
|
37
|
-
"standard": "^16.0.
|
|
37
|
+
"standard": "^16.0.4"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=10"
|
package/test.js
CHANGED
|
@@ -1,47 +1,40 @@
|
|
|
1
|
-
'use strict'
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
console.error(e);
|
|
42
|
-
} finally {
|
|
43
|
-
await pool.close();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
main().catch(console.error);
|
|
1
|
+
'use strict'
|
|
2
|
+
const mssql = require('./')
|
|
3
|
+
|
|
4
|
+
const [, , max] = process.argv
|
|
5
|
+
|
|
6
|
+
const sqlConfig = {
|
|
7
|
+
password: 'P@ssw0rd',
|
|
8
|
+
database: 'test',
|
|
9
|
+
stream: false,
|
|
10
|
+
// driver: 'msnodesqlv8',
|
|
11
|
+
options: {
|
|
12
|
+
trustServerCertificate: true,
|
|
13
|
+
enableArithAbort: true,
|
|
14
|
+
encrypt: true,
|
|
15
|
+
abortTransactionOnError: false
|
|
16
|
+
},
|
|
17
|
+
pool: {
|
|
18
|
+
max: max ? parseInt(max) : 10,
|
|
19
|
+
min: 0
|
|
20
|
+
},
|
|
21
|
+
port: 1433,
|
|
22
|
+
user: 'sa',
|
|
23
|
+
server: 'localhost',
|
|
24
|
+
arrayRowMode: true
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
mssql.connect(sqlConfig).then((pool) => {
|
|
28
|
+
console.log('Connected to SQL server')
|
|
29
|
+
const request = pool.request()
|
|
30
|
+
request.stream = true
|
|
31
|
+
request.on('error', (err) => {
|
|
32
|
+
console.error('good', err)
|
|
33
|
+
})
|
|
34
|
+
return request.query('SELECT * FROM nontable')
|
|
35
|
+
}).catch((err) => {
|
|
36
|
+
console.error('bad', err)
|
|
37
|
+
}).then(() => {
|
|
38
|
+
console.log('Disconnecting from SQL server')
|
|
39
|
+
return mssql.close()
|
|
40
|
+
}).then(() => console.log('Disconnected'))
|