Projet de remplacement du "RPiPasserelle" d'Otec.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pyheatpump.sql 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. CREATE TABLE IF NOT EXISTS var_type (
  2. slabel CHAR(1) UNIQUE PRIMARY KEY,
  3. label VARCHAR(10) UNIQUE,
  4. type VARCHAR(10) NOT NULL,
  5. start_address INT NOT NULL DEFAULT 0,
  6. end_address INT NOT NULL DEFAULT 250
  7. );
  8. CREATE TABLE IF NOT EXISTS variable (
  9. type CHAR(1) NOT NULL,
  10. address INT NOT NULL,
  11. unit VARCHAR(5) NULL,
  12. last_update DATE NULL,
  13. FOREIGN KEY (type) REFERENCES var_type(slabel)
  14. ON DELETE CASCADE,
  15. PRIMARY KEY(type, address)
  16. );
  17. CREATE TABLE IF NOT EXISTS var_value (
  18. type CHAR(1) NOT NULL,
  19. address INT NOT NULL,
  20. time DATE DEFAULT CURRENT_TIMESTAMP,
  21. value INT NOT NULL,
  22. FOREIGN KEY (type) REFERENCES variable(type)
  23. ON DELETE CASCADE,
  24. FOREIGN KEY (address) REFERENCES variable(address)
  25. ON DELETE CASCADE,
  26. PRIMARY KEY(type, address, time)
  27. );
  28. INSERT INTO var_type (slabel, label, type, start_address, end_address) VALUES (
  29. 'A', 'Analog', 'float', 1, 500);
  30. INSERT INTO var_type (slabel, label, type, start_address, end_address) VALUES (
  31. 'I', 'Integer', 'int', 5002, 6252);
  32. INSERT INTO var_type (slabel, label, type, start_address, end_address) VALUES (
  33. 'D', 'Digital', 'boolean', 1, 1000);