我能够与knex版本0.21.16的mssql配置成功连接,但当我将knex版本更改为2.4.2
我收到错误
无法连接到12345.dev.abc.com:1433 - getaddrinfo ENOTFOUND 12345.dev.abc.com\AV01
有人遇到过类似的问题吗?我试图找出knex的发布文档,但我还没有运气。也试着看了例子,但每个人都遵循相同的结构。
“mssql”:“9.1.1”,“knex”:2.4.2
注意:访问数据库不需要端口号。
//配置
{
client: 'mssql',
connection: {
server: '12345.dev.abc.com\\AV01',
database: 'DAB70',
user: 'testsql',
password: 'testsql',
sendStringParametersAsUnicode: false,
requestTimeout: 6000000,
options: {
enableArithAbort: true,
sendStringParametersAsUnicode: false,
trustServerCertificate: true,
}
},
pool: {
max: 30
},
}
//db.js
let db = knex(config.database)
export default db
//usage
let result = await db('TEST_TABLE').select(['DATA']).where('ID', ID);
console.log(result);
//package.json
{
"name": "test",
"main": "src/app.js",
"description": "",
"version": "0.7.4",
"private": false,
"scripts": {
"start": "babel-node src/app.js",
"start-debug": "babel-node %NODE_DEBUG_OPTION% src/app.js",
},
"repository": {
"type": "git",
"url": ""
},
"engines": {
"node": "16.x"
},
"devDependencies": {
"babel-cli": "6.26.0",
"babel-eslint": "8.2.1",
"babel-plugin-root-import": "6.6.0",
"babel-plugin-transform-async-to-generator": "6.24.1",
"babel-plugin-transform-es2015-destructuring": "6.23.0",
"babel-plugin-transform-object-rest-spread": "6.26.0",
"babel-plugin-transform-runtime": "6.23.0",
"babel-polyfill": "6.26.0",
"babel-preset-env": "1.7.0",
"babel-register": "6.26.0",
"babel-resolver": "1.1.0",
"eslint": "8.37.0",
"eslint-config-standard": "17.0.0",
"eslint-plugin-html": "7.1.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-standard": "4.1.0",
"nyc": "15.1.0",
"should": "13.2.3",
"sinon": "15.0.3",
"standard-version": "9.5.0",
"supertest": "6.3.3",
"transform-runtime": "0.0.0"
},
"dependencies": {
"@hapi/hapi": "21.3.1",
"@hapi/inert": "7.1.0",
"@hapi/vision": "7.0.1",
"aguid": "2.0.0",
"babel-cli": "6.26.0",
"babel-eslint": "8.2.1",
"babel-polyfill": "6.26.0",
"babel-preset-env": "1.7.0",
"babel-register": "6.26.0",
"babel-resolver": "1.1.0",
"bookshelf": "1.2.0",
"bookshelf-default-select": "1.0.4",
"bookshelf-eloquent": "0.1.15",
"bookshelf-modelbase": "2.11.0",
"bookshelf-uuid": "1.0.1",
"boom": "7.2.0",
"cfenv": "1.2.4",
"es6-promisify": "7.0.0",
"fast-json-patch": "3.1.1",
"ftp": "0.3.10",
"hapi-api-version": "2.3.1",
"hapi-auth-basic": "5.0.0",
"hapi-auth-cookie-jwt": "3.0.1",
"hapi-auth-jwt2": "10.4.0",
"hapi-server-session": "5.1.2",
"hapi-swagger": "16.0.1",
"inert": "5.1.0",
"javascript-state-machine": "3.1.0",
"joi": "17.9.1",
"joi-date-extensions": "1.1.1",
"joi-to-json-schema": "5.1.0",
"joi-to-swagger": "6.2.0",
"json_merger": "1.2.0",
"jsonwebtoken": "9.0.0",
"knex": "2.4.2",
"log4js": "6.9.1",
"mssql": "9.1.1",
"node-cache": "5.1.2",
"node-cron": "3.0.2",
"node-schedule": "2.1.1",
"node-stringify": "0.2.1",
"nodemailer": "6.9.1",
"nodemailer-shared": "2.0.0",
"object-hash": "3.0.0",
"openid-client": "5.4.0",
"request": "2.88.2",
"request-promise": "4.2.2",
"tedious": "15.1.3",
"unidecode": "0.1.8",
"vertica": "0.5.5",
"vision": "5.3.1",
"yar": "9.0.1"
}
}
1条答案
按热度按时间5ssjco0h1#
我也面临着同样的问题。为我工作的配置: