diff --git a/storage/mysql/68-mysql.html b/storage/mysql/68-mysql.html index 7e50d409..bc501580 100644 --- a/storage/mysql/68-mysql.html +++ b/storage/mysql/68-mysql.html @@ -79,6 +79,7 @@

This node uses the query operation against the configured database. This does allow both INSERTS and DELETES. By it's very nature it allows SQL injection... so be careful out there...

msg.topic must hold the query for the database, and the result is returned in msg.payload.

+

msg.payload can contain an array of values to bind to the topic.

Typically the returned payload will be an array of the result rows.

If nothing is found for the key then null is returned,

The reconnect timeout in milliseconds can be changed by adding a line to settings.js diff --git a/storage/mysql/68-mysql.js b/storage/mysql/68-mysql.js index 1c090a1f..01954dc3 100644 --- a/storage/mysql/68-mysql.js +++ b/storage/mysql/68-mysql.js @@ -101,7 +101,8 @@ module.exports = function(RED) { node.on("input", function(msg) { if (typeof msg.topic === 'string') { //console.log("query:",msg.topic); - node.mydbConfig.connection.query(msg.topic, function(err, rows) { + var bind = Array.isArray(msg.payload) ? msg.payload : []; + node.mydbConfig.connection.query(msg.topic, bind, function(err, rows) { if (err) { node.warn(err); } else { msg.payload = rows; diff --git a/storage/mysql/package.json b/storage/mysql/package.json index 3bd6818e..d12eb4ac 100644 --- a/storage/mysql/package.json +++ b/storage/mysql/package.json @@ -1,9 +1,9 @@ { "name" : "node-red-node-mysql", - "version" : "0.0.4", + "version" : "0.0.5", "description" : "A Node-RED node to read and write to a MySQL database", "dependencies" : { - "mysql" : "2.3.*" + "mysql" : "2.5.*" }, "repository" : { "type":"git", diff --git a/storage/sqlite/package.json b/storage/sqlite/package.json index 3b9a30a0..b8e674d2 100644 --- a/storage/sqlite/package.json +++ b/storage/sqlite/package.json @@ -1,9 +1,9 @@ { "name" : "node-red-node-sqlite", - "version" : "0.0.3", + "version" : "0.0.4", "description" : "A sqlite node for Node-RED", "dependencies" : { - "sqlite3" : "2.x" + "sqlite3" : "3.0.*" }, "repository" : { "type":"git", diff --git a/storage/sqlite/sqlite.html b/storage/sqlite/sqlite.html index fb1c6a9e..60f5d363 100644 --- a/storage/sqlite/sqlite.html +++ b/storage/sqlite/sqlite.html @@ -50,6 +50,7 @@

This node uses the db.all operation against the configured database. This does allow INSERTS, UPDATES and DELETES. By it's very nature it is SQL injection... so be careful out there...

msg.topic must hold the query for the database, and the result is returned in msg.payload.

+

msg.payload can contain an array of values to bind to the topic.

Typically the returned payload will be an array of the result rows, (or an error).

The reconnect timeout in milliseconds can be changed by adding a line to settings.js

sqliteReconnectTime: 20000,

diff --git a/storage/sqlite/sqlite.js b/storage/sqlite/sqlite.js index 9a7e3b34..69121fc9 100644 --- a/storage/sqlite/sqlite.js +++ b/storage/sqlite/sqlite.js @@ -57,7 +57,8 @@ module.exports = function(RED) { node.on("input", function(msg) { if (typeof msg.topic === 'string') { //console.log("query:",msg.topic); - node.mydbConfig.db.all(msg.topic, function(err, row) { + var bind = Array.isArray(msg.payload) ? msg.payload : []; + node.mydbConfig.db.all(msg.topic, bind, function(err, row) { if (err) { node.warn(err); } else { msg.payload = row;