- 11
- 68 254
FACTOMATION ( IOT solutions )
India
เข้าร่วมเมื่อ 26 มิ.ย. 2017
Industrial Internet of things (IIOT), tutorials, ideas,
generate MySQL demo database with millions of rows with time stamp in 3 minute.
generate MySQL demo database with millions of rows with time stamp in 3 minute.
//First formula
//months to second 6 Month = 15552000 sec
//Series interval = 3 sec
//Suppose today date is ‘Saturday, January 23, 2021 12:34:40 PM GMT+05:30’
//Epoch time will be 1611385480 google Epoch time to know more..
//six months back Epoh time will be 1611385480 - 15552000 (6 months time in seconds) = 1595833480
//First create table
CREATE TABLE demoplant ( id INT PRIMARY KEY AUTO_INCREMENT, tim TIMESTAMP DEFAULT CURRENT_TIMESTAMP, machine1 INT, machine2 INT, machine3 INT, machine4 INT, machine5 INT, machine6 INT);
// For create procedure
DELIMITER //
CREATE PROCEDURE filldemodata (IN NumRows INT, IN Unix_epo INT, IN interval_sec INT, IN MinVal1 INT, IN MaxVal1 INT, IN MinVal2 INT, IN MaxVal2 INT, IN MinVal3 INT, IN MaxVal3 INT, IN MinVal4 INT, IN MaxVal4 INT, IN MinVal5 INT, IN MaxVal5 INT, IN MinVal6 INT, IN MaxVal6 INT)
BEGIN
DECLARE i INT;
DECLARE J INT;
DECLARE k INT;
SET i = 1;
SET j = Unix_epo;
SET k = interval_sec;
START TRANSACTION;
WHILE i = NumRows DO
INSERT INTO demoplant (tim, machine1, machine2, machine3, machine4, machine5, machine6) VALUES (from_unixtime (j, '%Y-%m-%d %H:%i:%s'), MinVal1 + CEIL(RAND() * (MaxVal1 - MinVal1)), MinVal2 + CEIL(RAND() * (MaxVal2 - MinVal2)), MinVal3 + CEIL(RAND() * (MaxVal3 - MinVal3)), MinVal4 + CEIL(RAND() * (MaxVal4 - MinVal4)), MinVal5 + CEIL(RAND() * (MaxVal5 - MinVal5)), MinVal6 + CEIL(RAND() * (MaxVal1 - MinVal6)) );
SET i = i + 1;
SET j = j + k;
END WHILE;
COMMIT;
END//
DELIMITER ;
//CALLING PROCEDURE
//CALL filldemodata (number of rows, 6months back epoch time, series interval in seconds, machine1 min value, machine1 max value, machine2 min value, machine2 max value, machine3 min value, //machine3 max value, machine4 min value, machine4 max value, machine5 min value, machine5 max value, machine6 min value, machine6 max value);
//Example
Call filldemodata ( 5200000, 1595833480, 3, 100, 105, 200, 210, 120, 127, 160, 168, 180, 186, 250, 260);
//First formula
//months to second 6 Month = 15552000 sec
//Series interval = 3 sec
//Suppose today date is ‘Saturday, January 23, 2021 12:34:40 PM GMT+05:30’
//Epoch time will be 1611385480 google Epoch time to know more..
//six months back Epoh time will be 1611385480 - 15552000 (6 months time in seconds) = 1595833480
//First create table
CREATE TABLE demoplant ( id INT PRIMARY KEY AUTO_INCREMENT, tim TIMESTAMP DEFAULT CURRENT_TIMESTAMP, machine1 INT, machine2 INT, machine3 INT, machine4 INT, machine5 INT, machine6 INT);
// For create procedure
DELIMITER //
CREATE PROCEDURE filldemodata (IN NumRows INT, IN Unix_epo INT, IN interval_sec INT, IN MinVal1 INT, IN MaxVal1 INT, IN MinVal2 INT, IN MaxVal2 INT, IN MinVal3 INT, IN MaxVal3 INT, IN MinVal4 INT, IN MaxVal4 INT, IN MinVal5 INT, IN MaxVal5 INT, IN MinVal6 INT, IN MaxVal6 INT)
BEGIN
DECLARE i INT;
DECLARE J INT;
DECLARE k INT;
SET i = 1;
SET j = Unix_epo;
SET k = interval_sec;
START TRANSACTION;
WHILE i = NumRows DO
INSERT INTO demoplant (tim, machine1, machine2, machine3, machine4, machine5, machine6) VALUES (from_unixtime (j, '%Y-%m-%d %H:%i:%s'), MinVal1 + CEIL(RAND() * (MaxVal1 - MinVal1)), MinVal2 + CEIL(RAND() * (MaxVal2 - MinVal2)), MinVal3 + CEIL(RAND() * (MaxVal3 - MinVal3)), MinVal4 + CEIL(RAND() * (MaxVal4 - MinVal4)), MinVal5 + CEIL(RAND() * (MaxVal5 - MinVal5)), MinVal6 + CEIL(RAND() * (MaxVal1 - MinVal6)) );
SET i = i + 1;
SET j = j + k;
END WHILE;
COMMIT;
END//
DELIMITER ;
//CALLING PROCEDURE
//CALL filldemodata (number of rows, 6months back epoch time, series interval in seconds, machine1 min value, machine1 max value, machine2 min value, machine2 max value, machine3 min value, //machine3 max value, machine4 min value, machine4 max value, machine5 min value, machine5 max value, machine6 min value, machine6 max value);
//Example
Call filldemodata ( 5200000, 1595833480, 3, 100, 105, 200, 210, 120, 127, 160, 168, 180, 186, 250, 260);
มุมมอง: 733
วีดีโอ
How to insert current timestamp in MySQL
มุมมอง 4.8K4 ปีที่แล้ว
How to insert current timestamp in MySQL steps 1. create database test3; //* in my case name is test3)// 2. create table demo ( pr int primary key auto_increment, time_stamp timestamp default current_timestamp, var1 int, var2 int, var3 int); 3. insert into demo ( var1, var2, var3) values (10, 11,333), (22,30,3); 4. select * from demo; thanks for watching
mysql primary key reset
มุมมอง 2.2K4 ปีที่แล้ว
Reset mysql primary key. sometimes it may required to reset the value here is simple query //first delete the primary key ALTER TABLE Table_Name DROP ID; //then set increment to 1 ALTER TABLE Table_Name AUTO_INCREMENT = 1; //recreate the Id column ALTER TABLE Table_Name ADD ID int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
how to send data to Thingsboard via Nodered MQTT
มุมมอง 10K4 ปีที่แล้ว
Send data to Thingsboard via Nodered MQTT while Thingsboard and nodered is installed on same vps server (centos 7) This way multiple instance of MQTT can be used to send and receive data.
nodered mysql data logger
มุมมอง 18K4 ปีที่แล้ว
//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 N...
Node red - understanding Inject node and debug node.
มุมมอง 1304 ปีที่แล้ว
Node red - understanding Inject node and debug node.
Data logging MQTT to PostgreSQL via Node red
มุมมอง 12K4 ปีที่แล้ว
This is basic to intermediate level tutorial configuration:- node-red, PostgreSQL and pgAdmin is installed on same Ubuntu machine. lots of tutorial available how to install PostgreSQL and pgAdmin. On node red some plant data is received on MQTT node as string. my goal is to log MQTT data to PostgreSQL with time stamp. so I can use it further for visualisation and generating reports. Step 1: - I...
How to install Ubuntu minimal on vmware
มุมมอง 1.5K4 ปีที่แล้ว
How to install Ubuntu minimal on vmware. Ubuntu minimal takes less space and runs faster than desktop version. link for download iso file archive.ubuntu.com/ubuntu/dists/bionic/main/installer-amd64/current/images/netboot/mini.iso link for installing ssh linuxize.com/post/how-to-enable-ssh-on-ubuntu-18-04/
How to split json object message on node red MQTT broker
มุมมอง 16K4 ปีที่แล้ว
How to split MQTT json object message into individual payloads. code used in function node is var test = msg.payload; tag1 = {payload:test.values[0].v}; tag2 = {payload:test.values[1].v}; tag3 = {payload:test.values[2].v}; tag4 = {payload:test.values[3].v}; tag5 = {payload:test.values[4].v}; tag6 = {payload:test.values[5].v}; tag7 = {payload:test.values[6].v}; tag8 = {payload:test.values[7].v};...
Node red, MQTT, multiple message on single Topic
มุมมอง 2.1K4 ปีที่แล้ว
json is used to pass multiple tags on single topic