This commit is contained in:
PaulVua
2025-02-10 10:06:16 +01:00
parent 7cac769795
commit 1cb1b05b51
10 changed files with 200 additions and 77 deletions

View File

@@ -15,7 +15,19 @@ import sqlite3
conn = sqlite3.connect("/var/www/nebuleair_pro_4g/sqlite/sensors.db")
cursor = conn.cursor()
# Create a table 1
# Create a table timer
cursor.execute("""
CREATE TABLE IF NOT EXISTS timestamp_table (
id INTEGER PRIMARY KEY CHECK (id = 1), -- Enforce single row by using fixed ID
last_updated DATETIME NOT NULL
)
""")
cursor.execute("""
INSERT INTO timestamp_table (id, last_updated) VALUES (1, CURRENT_TIMESTAMP);
""")
# Create a table NPM
cursor.execute("""
CREATE TABLE IF NOT EXISTS data_NPM (
timestamp TEXT,
@@ -27,7 +39,7 @@ CREATE TABLE IF NOT EXISTS data_NPM (
)
""")
# Create a table 2
# Create a table BME280
cursor.execute("""
CREATE TABLE IF NOT EXISTS data_BME280 (
timestamp TEXT,
@@ -37,7 +49,7 @@ CREATE TABLE IF NOT EXISTS data_BME280 (
)
""")
# Create a table 3
# Create a table cairsens
cursor.execute("""
CREATE TABLE IF NOT EXISTS data_envea (
timestamp TEXT,
@@ -49,7 +61,7 @@ CREATE TABLE IF NOT EXISTS data_envea (
)
""")
# Create a table 4
# Create a table NPM_5ch
cursor.execute("""
CREATE TABLE IF NOT EXISTS data_NPM_5channels (
timestamp TEXT,