Cancelling a Postgres insert if a value already exists in a column - javascript

so I'm trying to only run a PostgreSQL insert in a Node.js file if there isn't a row that exists in the table that contains a specific value...
db.query(`INSERT INTO table (col1, col2, col3, col4, col5) VALUES($1, $2, $3, $4, $5)`, ["default", value2, value3, value4, value5], (err, res) => {
if (err) {
console.error(err);
return;
}
});
Essentially, I'm trying to only insert into the table if there is NOT any row in the table with value2 as the value of its col2. Is this possible?
UPDATE:
The error when I'm using ON CONFLICT looks like:
2021-05-09T20:06:37.356493+00:00 app[web.1]: error: there is no unique or exclusion constraint matching the ON CONFLICT specification
2021-05-09T20:06:37.356494+00:00 app[web.1]: at Parser.parseErrorMessage (/app/node_modules/pg-protocol/dist/parser.js:287:98)
2021-05-09T20:06:37.356494+00:00 app[web.1]: at Parser.handlePacket (/app/node_modules/pg-protocol/dist/parser.js:126:29)
2021-05-09T20:06:37.356495+00:00 app[web.1]: at Parser.parse (/app/node_modules/pg-protocol/dist/parser.js:39:38)
2021-05-09T20:06:37.356496+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/pg-protocol/dist/index.js:11:42)
2021-05-09T20:06:37.356497+00:00 app[web.1]: at TLSSocket.emit (events.js:315:20)
2021-05-09T20:06:37.356498+00:00 app[web.1]: at addChunk (internal/streams/readable.js:309:12)
2021-05-09T20:06:37.356498+00:00 app[web.1]: at readableAddChunk (internal/streams/readable.js:284:9)
2021-05-09T20:06:37.356498+00:00 app[web.1]: at TLSSocket.Readable.push (internal/streams/readable.js:223:10)
2021-05-09T20:06:37.356499+00:00 app[web.1]: at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23) {
2021-05-09T20:06:37.356499+00:00 app[web.1]: length: 148,
2021-05-09T20:06:37.356500+00:00 app[web.1]: severity: 'ERROR',
2021-05-09T20:06:37.356500+00:00 app[web.1]: code: '42P10',
2021-05-09T20:06:37.356500+00:00 app[web.1]: detail: undefined,
2021-05-09T20:06:37.356501+00:00 app[web.1]: hint: undefined,
2021-05-09T20:06:37.356501+00:00 app[web.1]: position: undefined,
2021-05-09T20:06:37.356501+00:00 app[web.1]: internalPosition: undefined,
2021-05-09T20:06:37.356501+00:00 app[web.1]: internalQuery: undefined,
2021-05-09T20:06:37.356502+00:00 app[web.1]: where: undefined,
2021-05-09T20:06:37.356502+00:00 app[web.1]: schema: undefined,
2021-05-09T20:06:37.356502+00:00 app[web.1]: table: undefined,
2021-05-09T20:06:37.356503+00:00 app[web.1]: column: undefined,
2021-05-09T20:06:37.356503+00:00 app[web.1]: dataType: undefined,
2021-05-09T20:06:37.356503+00:00 app[web.1]: constraint: undefined,
2021-05-09T20:06:37.356503+00:00 app[web.1]: file: 'plancat.c',
2021-05-09T20:06:37.356503+00:00 app[web.1]: line: '835',
2021-05-09T20:06:37.356504+00:00 app[web.1]: routine: 'infer_arbiter_indexes'
2021-05-09T20:06:37.356504+00:00 app[web.1]:
}

Related

code: 'ER_ACCESS_DENIED_ERROR' WITH TypeORM

I am having a issue using typeORM to a CRUD application. I get this error when i try to connect the server to the database (MySQL). The credencials are correct, but I still have error. I am using ormconfig.json
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'#'localhost' (using password: YES)
at Handshake.Sequence._packetToError (/home/ivan/Programming/TypeORM_CRUD/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Handshake.ErrorPacket (/home/ivan/Programming/TypeORM_CRUD/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
at Protocol._parsePacket (/home/ivan/Programming/TypeORM_CRUD/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/home/ivan/Programming/TypeORM_CRUD/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/home/ivan/Programming/TypeORM_CRUD/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/home/ivan/Programming/TypeORM_CRUD/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/home/ivan/Programming/TypeORM_CRUD/node_modules/mysql/lib/Connection.js:88:28)
at Socket.<anonymous> (/home/ivan/Programming/TypeORM_CRUD/node_modules/mysql/lib/Connection.js:526:10)
at Socket.emit (node:events:390:28)
at addChunk (node:internal/streams/readable:315:12)
--------------------
at Protocol._enqueue (/home/ivan/Programming/TypeORM_CRUD/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/home/ivan/Programming/TypeORM_CRUD/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at PoolConnection.connect (/home/ivan/Programming/TypeORM_CRUD/node_modules/mysql/lib/Connection.js:116:18)
at Pool.getConnection (/home/ivan/Programming/TypeORM_CRUD/node_modules/mysql/lib/Pool.js:48:16)
at /home/ivan/Programming/TypeORM_CRUD/node_modules/typeorm/driver/mysql/MysqlDriver.js:863:18
at new Promise (<anonymous>)
at MysqlDriver.createPool (/home/ivan/Programming/TypeORM_CRUD/node_modules/typeorm/driver/mysql/MysqlDriver.js:860:16)
at MysqlDriver.<anonymous> (/home/ivan/Programming/TypeORM_CRUD/node_modules/typeorm/driver/mysql/MysqlDriver.js:288:51)
at step (/home/ivan/Programming/TypeORM_CRUD/node_modules/tslib/tslib.js:143:27)
at Object.next (/home/ivan/Programming/TypeORM_CRUD/node_modules/tslib/tslib.js:124:57) {
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlMessage: "Access denied for user 'root'#'localhost' (using password: YES)",
sqlState: '28000',
fatal: true
}
The ormconfig.json file are:
{
"type": "mysql",
"host": "localhost",
"username": "root",
"password": "password",
"database": "database_app",
"entities": ["dist/entity/**/*.js"],
"synchronize": true
}

Is there a way to disable security on heroku Postgres db?

My project doesn't involve any private information, so I don't care about vulnerabilities.
I am certain that the connection between the App/server and the DB is the problem.
I tried to looking on Youtube and on Google, but the answers were outdated or they just didn't work for me. However, connecting to the database with heroku psql (cli) or connecting with pgAdmin4 using db creds and querying, creating tables works fine.
Following this guy's tutorial
https://github.com/ousecTic/pern-deploy-tutorial
Errors:
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: true,
});
------------------------------------------------------------------------
2022-02-12T11:02:33.058860+00:00 heroku[web.1]: State changed from starting to up
2022-02-12T11:02:34.275213+00:00 app[web.1]: node:internal/process/promises:265
2022-02-12T11:02:34.275240+00:00 app[web.1]: triggerUncaughtException(err, true /* fromPromise */);
2022-02-12T11:02:34.275241+00:00 app[web.1]: ^
2022-02-12T11:02:34.275241+00:00 app[web.1]:
2022-02-12T11:02:34.275241+00:00 app[web.1]: Error: self signed certificate
2022-02-12T11:02:34.275242+00:00 app[web.1]: at TLSSocket.onConnectSecure (node:_tls_wrap:1530:34)
2022-02-12T11:02:34.275242+00:00 app[web.1]: at TLSSocket.emit (node:events:520:28)
2022-02-12T11:02:34.275242+00:00 app[web.1]: at TLSSocket._finishInit (node:_tls_wrap:944:8)
2022-02-12T11:02:34.275243+00:00 app[web.1]: at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:725:12) {
2022-02-12T11:02:34.275243+00:00 app[web.1]: code: 'DEPTH_ZERO_SELF_SIGNED_CERT'
2022-02-12T11:02:34.275243+00:00 app[web.1]: }
-------------------------------------------------------------------------
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
});
------------------------------------------------------------------------------------
2022-02-12T11:19:13.660398+00:00 app[web.1]: { description: 'jhoipjo' } <<console.log()
2022-02-12T11:19:13.681933+00:00 app[web.1]: no pg_hba.conf entry for host "3.86.151.70", user "user", database "database", SSL off
------------------------------------------------------------------------------------
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: false,
});
------------------------------------------------------------------------------------
2022-02-12T11:58:50.711988+00:00 app[web.1]: /app/node_modules/pg-protocol/dist/parser.js:287
2022-02-12T11:58:50.712007+00:00 app[web.1]: const message = name === 'notice' ? new messages_1.NoticeMessage(length, messageValue) : new messages_1.DatabaseError(messageValue, length, name);
2022-02-12T11:58:50.712008+00:00 app[web.1]: ^
2022-02-12T11:58:50.712009+00:00 app[web.1]:
2022-02-12T11:58:50.712010+00:00 app[web.1]: error: no pg_hba.conf entry for host "3.236.98.211", user "user", database "database", SSL off
2022-02-12T11:58:50.712010+00:00 app[web.1]: at Parser.parseErrorMessage (/app/node_modules/pg-protocol/dist/parser.js:287:98)
2022-02-12T11:58:50.712011+00:00 app[web.1]: at Parser.handlePacket (/app/node_modules/pg-protocol/dist/parser.js:126:29)
2022-02-12T11:58:50.712012+00:00 app[web.1]: at Parser.parse (/app/node_modules/pg-protocol/dist/parser.js:39:38)
2022-02-12T11:58:50.712013+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/pg-protocol/dist/index.js:11:42)
2022-02-12T11:58:50.712014+00:00 app[web.1]: at Socket.emit (node:events:520:28)
2022-02-12T11:58:50.712014+00:00 app[web.1]: at addChunk (node:internal/streams/readable:315:12)
2022-02-12T11:58:50.712014+00:00 app[web.1]: at readableAddChunk (node:internal/streams/readable:289:9)
2022-02-12T11:58:50.712014+00:00 app[web.1]: at Socket.Readable.push (node:internal/streams/readable:228:10)
2022-02-12T11:58:50.712015+00:00 app[web.1]: at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
2022-02-12T11:58:50.712015+00:00 app[web.1]: length: 166,
2022-02-12T11:58:50.712016+00:00 app[web.1]: severity: 'FATAL',
2022-02-12T11:58:50.712016+00:00 app[web.1]: code: '28000',
2022-02-12T11:58:50.712016+00:00 app[web.1]: detail: undefined,
2022-02-12T11:58:50.712017+00:00 app[web.1]: hint: undefined,
2022-02-12T11:58:50.712017+00:00 app[web.1]: position: undefined,
2022-02-12T11:58:50.712017+00:00 app[web.1]: internalPosition: undefined,
2022-02-12T11:58:50.712018+00:00 app[web.1]: internalQuery: undefined,
2022-02-12T11:58:50.712018+00:00 app[web.1]: where: undefined,
2022-02-12T11:58:50.712018+00:00 app[web.1]: schema: undefined,
2022-02-12T11:58:50.712018+00:00 app[web.1]: table: undefined,
2022-02-12T11:58:50.712019+00:00 app[web.1]: column: undefined,
2022-02-12T11:58:50.712019+00:00 app[web.1]: dataType: undefined,
2022-02-12T11:58:50.712019+00:00 app[web.1]: constraint: undefined,
2022-02-12T11:58:50.712019+00:00 app[web.1]: file: 'auth.c',
2022-02-12T11:58:50.712019+00:00 app[web.1]: line: '496',
2022-02-12T11:58:50.712019+00:00 app[web.1]: routine: 'ClientAuthentication'
2022-02-12T11:58:50.712020+00:00 app[web.1]: }
------------------------------------------------------------------------------------
the app was a nodejs blogging app so there was no need for security
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false,
},
});

I am getting an error while connecting to mysql database

I am trying to input some data into a mysql database, but I can't connect to it.
My code:
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "yourusername",
password: "yourpassword"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
});
I have also installed mysql into my system by using npm install mysql in cmd. Whenever I try to execute the above code, I get this error:
C:\Users\Abhishek\Desktop\Data scraping\scraping.js:60
if (err) throw err;
^
Error: connect ECONNREFUSED 127.0.0.1:3306
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1129:16)
--------------------
at Protocol._enqueue (C:\Users\Abhishek\node_modules\mysql\lib\protocol\Protocol.js:144:48)
at Protocol.handshake (C:\Users\Abhishek\node_modules\mysql\lib\protocol\Protocol.js:51:23)
at Connection.connect (C:\Users\Abhishek\node_modules\mysql\lib\Connection.js:116:18)
at Object.<anonymous> (C:\Users\Abhishek\Desktop\Data scraping\scraping.js:59:5)
at Module._compile (node:internal/modules/cjs/loader:1083:30)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1112:10)
at Module.load (node:internal/modules/cjs/loader:948:32)
at Function.Module._load (node:internal/modules/cjs/loader:789:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:72:12)
at node:internal/main/run_main_module:17:47 {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306,
fatal: true
}
How do I fix this?

I'm getting a Error using node package mysql v2.16.0 while connecting to database Error: Packets out of order. Got: 80 Expected: 0

versions:
node > 11.4.0
mysql(node package) > 2.16.0
phpMyAdmin > 4.8.3
MySQL > 5.7
I'm using this code:
const mysql = require('mysql');
let db = mysql.createConnection({
host:'hidden',
port:'hidden',
user:'hidden',
password:'hidden',
database: 'hidden',
dubug: true
});
sqlfn.createTable('Internal', db, 'test_table', (result, err) => {
if(err) {console.log(err.stack); return};
console.log('Create OK: ', result);
});
From the function file sqlfn:
exports.createTable = (req, db, name, callback) => {
let query_string = String(`CREATE TABLE ${name} (uid VARCHAR(255), name VARCHAR(255), type VARCHAR(255), data VARCHAR(255), modified VARCHAR(255))`);
db.query(query_string, (err, result) => {
if(err) fn.logit(req, 'SQL', 'error', `in <createTable> ${err}`);
callback(result, err);
});
};
This is the error that I am getting:
>
Error: Packets out of order. Got: 80 Expected: 0
at Parser.write (C:\Users\hidden\Documents\Git\hidden\node_modules\mysql\lib\protocol\Parser.js:42:19)
at Protocol.write (C:\Users\hidden\Documents\Git\hidden\node_modules\mysql\lib\protocol\Protocol.js:38:16)
at Socket. (C:\Users\hidden\Documents\Git\hidden\node_modules\mysql\lib\Connection.js:91:28)
at Socket. (C:\Users\hidden\Documents\Git\hidden\node_modules\mysql\lib\Connection.js:502:10)
at Socket.emit (events.js:189:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:145:17)
--------------------
at Protocol._enqueue (C:\Users\hidden\Documents\Git\hidden\node_modules\mysql\lib\protocol\Protocol.js:144:48) at Protocol.handshake (C:\Users\hidden\Documents\Git\hidden\node_modules\mysql\lib\protocol\Protocol.js:51:23) at Connection.connect (C:\Users\hidden\Documents\Git\hidden\node_modules\mysql\lib\Connection.js:118:18)
at Connection._implyConnect (C:\Users\hidden\Documents\Git\hidden\node_modules\mysql\lib\Connection.js:453:10) at Connection.query (C:\Users\hidden\Documents\Git\hidden\node_modules\mysql\lib\Connection.js:198:8)
at Object.exports.createTable (C:\Users\hidden\Documents\Git\hidden\components\functions\sql.js:36:8)
at Object. (C:\Users\hidden\Documents\Git\hidden\components\controllers\controll_admin.js:22:7)
at Module._compile (internal/modules/cjs/loader.js:723:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:734:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
If anyone know how i can fix or work-around this I'd love some feedback and help regarding this.
thank you.
:)
I was getting the same error and it was because I was not setting the correct port for my database which was 3305 instead of the default 3306

MySql - not connecting in nodejs

im trying to set it up so my twitch bot can connect to a database to store data. however i cannot seem to work out how to connect. Ive inputted all the correct data (i can connect with the credetials with a client) and it still isnt connecting.
var sql = require('mssql');
var sqlConfig = {
server: "x",
username: "x",
password: "x",
database: "x"
};
(async function () {
try {
console.log("sql connecting......")
let pool = await sql.connect(sqlConfig)
let result = await pool.request()
.query('select * from Subject') // subject is my database table name
console.log(result )
} catch (err) {
console.log(err);
}
})()
that errors this :
{ ConnectionError: Failed to connect to sql2.freemysqlhosting.net:1433 in 15000ms
at Connection.tedious.once.err (H:\Node JS\TwitchBot\node_modules\mssql\lib\tedious.js:216:17)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at Connection.emit (events.js:211:7)
at Connection.connectTimeout (H:\Node JS\TwitchBot\node_modules\tedious\lib\connection.js:924:12)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
code: 'ETIMEOUT',
originalError:
{ ConnectionError: Failed to connect to sql2.freemysqlhosting.net:1433 in 15000ms
at ConnectionError (H:\Node JS\TwitchBot\node_modules\tedious\lib\errors.js:12:12)
at Connection.connectTimeout (H:\Node JS\TwitchBot\node_modules\tedious\lib\connection.js:924:28)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
message: 'Failed to connect to sql2.freemysqlhosting.net:1433 in 15000ms',
code: 'ETIMEOUT' },
name: 'ConnectionError' }
OUTCOME 1 this didnt work because it was not mysql is mssql. Im a bit stupid sorry guys:
throw new RangeError('Index out of range');
RangeError: Index out of range
at checkOffset (buffer.js:977:11)
at Buffer.readUInt8 (buffer.js:1015:5)
at Packet.isLast (H:\Node JS\TwitchBot\node_modules\tedious\lib\packet.js:116:29)
at ReadablePacketStream.<anonymous> (H:\Node JS\TwitchBot\node_modules\tedious\lib\message-io.js:101:18)
at emitOne (events.js:116:13)
at ReadablePacketStream.emit (events.js:211:7)
at addChunk (H:\Node JS\TwitchBot\node_modules\tedious\node_modules\readable-stream\lib\_stream_readable.js:291:12)
at readableAddChunk (H:\Node JS\TwitchBot\node_modules\tedious\node_modules\readable-stream\lib\_stream_readable.js:278:11)
at ReadablePacketStream.Readable.push (H:\Node JS\TwitchBot\node_modules\tedious\node_modules\readable-stream\lib\_stream_readable.js:245:10)
at ReadablePacketStream.Transform.push (H:\Node JS\TwitchBot\node_modules\tedious\node_modules\readable-stream\lib\_stream_transform.js:148:32)
OUTPUT 2 :
Error: connect ECONNREFUSED 127.0.0.1:3306
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
--------------------
at Protocol._enqueue (H:\Node JS\TwitchBot\node_modules\mysql\lib\protocol\Protocol.js:145:48)
at Protocol.handshake (H:\Node JS\TwitchBot\node_modules\mysql\lib\protocol\Protocol.js:52:23)
at Connection.connect (H:\Node JS\TwitchBot\node_modules\mysql\lib\Connection.js:130:18)
at Object.<anonymous> (H:\Node JS\TwitchBot\fb.js:11:12)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
OUTPUT 3:
Error: ER_ACCESS_DENIED_ERROR: Access denied for user ''#'MY isp identifier' (using password: YES)
at Handshake.Sequence._packetToError (H:\Node JS\TwitchBot\node_modules\mysql\lib\protocol\sequences\Sequence.js:52:14)
at Handshake.ErrorPacket (H:\Node JS\TwitchBot\node_modules\mysql\lib\protocol\sequences\Handshake.js:130:18)
at Protocol._parsePacket (H:\Node JS\TwitchBot\node_modules\mysql\lib\protocol\Protocol.js:279:23)
at Parser.write (H:\Node JS\TwitchBot\node_modules\mysql\lib\protocol\Parser.js:76:12)
at Protocol.write (H:\Node JS\TwitchBot\node_modules\mysql\lib\protocol\Protocol.js:39:16)
at Socket.<anonymous> (H:\Node JS\TwitchBot\node_modules\mysql\lib\Connection.js:103:28)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
--------------------
at Protocol._enqueue (H:\Node JS\TwitchBot\node_modules\mysql\lib\protocol\Protocol.js:145:48)
at Protocol.handshake (H:\Node JS\TwitchBot\node_modules\mysql\lib\protocol\Protocol.js:52:23)
at Connection.connect (H:\Node JS\TwitchBot\node_modules\mysql\lib\Connection.js:130:18)
at Object.<anonymous> (H:\Node JS\TwitchBot\fb.js:11:12)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
You're using the mssql npm library to connect to a mysql database. These are two completely different DBMS systems and as such, are not cross compatible. You need to use the correct kind of client.
I know you're trying to connect to a mysql db because in the URL I can see https://www.freemysqlhosting.net/ which only supports hosting of a `mysql database. This means you need to use the correct kind of client.
To do this, you can use the mysql npm dependency, with a code block like this:
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'x',
user : 'x',
password : 'x',
database : 'x'
});
connection.connect();
connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
if (error) throw error;
console.log('The solution is: ', results[0].solution);
});
connection.end();
This will open a connection using the appropriate protocol and allow you to access your database.
Extra Reading
I'd read about the concept of a DBMS to fill up your understanding of why this code block hasn't worked.
Problem fixed by:
if you are using mssql according to npmjs.com/package/mssql you should replace host by server on sqlConfig object. (host is for mysql, server is for mssql)
set port on sqlConfig object:
var sqlConfig = {
server: "x",
username: "x",
password: "x",
database: "x",
port: "x"
};

Categories

Resources