Enable multiple statements

This commit is contained in:
2017-04-11 11:46:23 +02:00
parent ea7eecf3c6
commit 3340943f5e
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -4,7 +4,8 @@ var connection = mysql.createConnection({
user : 'root',
password : 'asdf1239',
database : 'smarthome',
timezone : 'utc'
timezone : 'utc',
multipleStatements: true
});
connection.connect(function(err) {
+1 -1
View File
@@ -158,7 +158,7 @@ router.get('/data/:device/group/:group', function(req, res) {
}
connection.query(
'SET @i:= 0; SELECT MIN(grp.`time`) AS t, AVG(grp.`HOV`) AS HOV, AVG(grp.`HTV`) AS HTV FROM (SELECT @i:=@i+1 AS `rownum`, FLOOR(@i/?) AS `datagrp`, `time`, `HOV`, `HTV` FROM `measurement` WHERE `device` = ? ORDER BY `time` DESC ) grp GROUP BY `datagrp`', [groupdiv, devid],
'SET @i:= 0; SELECT MIN(grp.`time`) AS time, AVG(grp.`HOV`) AS HOV, AVG(grp.`HTV`) AS HTV FROM (SELECT @i:=@i+1 AS `rownum`, FLOOR(@i/?) AS `datagrp`, `time`, `HOV`, `HTV` FROM `measurement` WHERE `device` = ? ORDER BY `time` DESC ) grp GROUP BY `datagrp`;', [groupdiv, devid],
function (error, results, fields) {
if (error) throw error;