You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

node-red-nodes-cf-sqldb-dashdb

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-nodes-cf-sqldb-dashdb - npm Package Compare versions

Comparing version

to
0.2.26

107

98-sqldb-dashdb-cf.js

@@ -279,2 +279,15 @@ /**

function connectToDB(node,db,connString) {
try {
console.log("dashDB query node: Opening db connection...");
db.openSync(connString);
console.log("dashDB query node: Connection open");
return false;
}
catch (e) {
node.error(e.message);
return true;
}
}
function dashDBQueryNode(n) {

@@ -287,2 +300,4 @@

var dashDBconfig = _getdashDBconfig(n);
var jail = false;
const util = require('util')

@@ -309,10 +324,3 @@ if (!dashDBconfig) {

try {
console.log("dashDB query node: Opening db connection...");
db.openSync(connString);
console.log("dashDB query node: Connection open");
}
catch (e) {
node.error(e.message);
}
jail = connectToDB(node,db,connString);

@@ -325,41 +333,52 @@ node.on("close", function() {

this.on('input', function(msg) {
if (query == "" || query == null) {
if (msg.payload == "" || msg.payload == null) {
node.error("dashDB query node: msg.payload is empty!");
return;
}
queryToUse = msg.payload;
}
else {
queryToUse = query;
}
var parameterValues=[];
if (params != "" && params != null) {
var path = pathToArray(params.toString());
console.log("Input node: pathToArray: " + path);
parameterValues = extractValues(msg, path);
console.log("Input node: parameterValues: " + parameterValues);
}
db.query(queryToUse,parameterValues,function (err, rows, moreResultSets) {
queryresult = null;
if (err) {
node.error("dashDB query node: " + err);
msg.error = err;
} else {
msg.error = null;
console.log("Fetching rows: " + rows);
console.log("value 1: " + JSON.stringify(rows[0]));
if (rows.length == 1) {queryresult = rows[0];}
else {
queryresult = [];
for (var i = 0; i < rows.length; i++) {
queryresult.push(rows[i]);
if (jail == true) {
console.log("dashDB Query Node: Because previous connection was dropped, attempting reconnect...");
jail = connectToDB(node,db,connString);
}
if (jail == false) {
if (query == "" || query == null) {
if (msg.payload == "" || msg.payload == null) {
node.error("dashDB query node: msg.payload is empty!");
return;
}
queryToUse = msg.payload;
}
else {
queryToUse = query;
}
var parameterValues=[];
if (params != "" && params != null) {
var path = pathToArray(params.toString());
console.log("Input node: pathToArray: " + path);
parameterValues = extractValues(msg, path);
console.log("Input node: parameterValues: " + parameterValues);
}
db.query(queryToUse,parameterValues,function (err, rows, moreResultSets) {
queryresult = null;
if (err) {
node.error("dashDB query node: " + err);
//debug: to print out the err message
//console.log(util.inspect(err, {showHidden: false, depth: null}))
if(err.message.indexOf('30081') > -1) {
console.log("30081 connection error detected; entering jail mode...");
jail = true;
}
msg.error = err;
} else {
msg.error = null;
console.log("Fetching rows: " + rows);
console.log("value 1: " + JSON.stringify(rows[0]));
if (rows.length == 1) {queryresult = rows[0];}
else {
queryresult = [];
for (var i = 0; i < rows.length; i++) {
queryresult.push(rows[i]);
}
}
}
}
msg.payload = queryresult;
node.send(msg);
});
msg.payload = queryresult;
node.send(msg);
});
}
});

@@ -366,0 +385,0 @@ }

{
"name" : "node-red-nodes-cf-sqldb-dashdb",
"version" : "0.2.25",
"version" : "0.2.26",
"description" : "Node-RED nodes to access SQLDB and dashDB services on Bluemix",

@@ -5,0 +5,0 @@ "dependencies" : {