-
-
Save lefred/c29134dd4b058995ac639194a0d80e92 to your computer and use it in GitHub Desktop.
procedure to load events in TideSQL table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DELIMITER // | |
| CREATE PROCEDURE load_events(IN loops INT) | |
| BEGIN | |
| DECLARE i INT DEFAULT 0; | |
| WHILE i < loops DO | |
| INSERT INTO events(ts, device_id, metric, value, payload) | |
| VALUES ( | |
| NOW(6) - INTERVAL FLOOR(RAND() * 86400) SECOND, | |
| FLOOR(1 + RAND() * 1000), | |
| ELT(FLOOR(1 + RAND() * 4), 'temperature', 'humidity', 'pressure', 'voltage'), | |
| RAND() * 100, | |
| JSON_OBJECT('source', 'generator', 'seq', i) | |
| ); | |
| SET i = i + 1; | |
| END WHILE; | |
| END// | |
| DELIMITER ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment