adds code


//query for creating table from inject topic CREATE TABLE steelfactory( p_Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Atime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, speed1 int DEFAULT NULL, speed2 int DEFAULT NULL, speed3 int DEFAULT NULL, speed4 int DEFAULT NULL, speed5 int DEFAULT NULL, speed6 int DEFAULT NULL, speed7 int DEFAULT NULL, speed8 int DEFAULT NULL ); //ON NODE INJECT NODE TOPIC for injecting values INSERT INTO steelfactory(speed1, speed2, speed3, speed4, speed5, speed6, speed7, speed8) VALUES (?,?,?,?,?,?,?,?); //ON NODE INJECT AS JSON [29, 33, 44, 33, 55, 66, 88, 44]; //Data convert function from mqtt var test = msg.payload; var tag1 = test.speed1; var tag2 = test.speed2; var tag3 = test.speed3; var tag4 = test.speed4; var tag5 = test.speed5; var tag6 = test.speed6; var tag7 = test.speed7; var tag8 = test.speed8; msg.payload = [tag1, tag2, tag3, tag4, tag5, tag6, tag7, tag8]; msg.topic = 'INSERT INTO steelfactory(speed1, speed2, speed3, speed4, speed5, speed6, speed7, speed8) VALUES (?,?,?,?,?,?,?,?);'; return msg;
Previous Post Next Post