This commit is contained in:
Your Name
2025-02-26 10:39:00 +01:00
parent 105e439199
commit d0e1ad18e9
10 changed files with 331 additions and 41 deletions

View File

@@ -26,7 +26,8 @@ CREATE TABLE IF NOT EXISTS timestamp_table (
)
""")
cursor.execute("""
INSERT INTO timestamp_table (id, last_updated) VALUES (1, CURRENT_TIMESTAMP);
INSERT OR REPLACE INTO timestamp_table (id, last_updated)
VALUES (1, CURRENT_TIMESTAMP);
""")
@@ -42,6 +43,14 @@ CREATE TABLE IF NOT EXISTS data_NPM (
)
""")
# Create a table CO2
cursor.execute("""
CREATE TABLE IF NOT EXISTS data_CO2 (
timestamp TEXT,
CO2 INTEGER
)
""")
# Create a table BME280
cursor.execute("""
CREATE TABLE IF NOT EXISTS data_BME280 (

View File

@@ -16,6 +16,7 @@ data_NPM_5channels
data_BME280
data_envea
timestamp_table
data_CO2
'''
@@ -45,7 +46,7 @@ if row:
print(f"[INFO] Deleting records older than: {cutoff_date_str}")
# List of tables to delete old data from
tables_to_clean = ["data_NPM", "data_NPM_5channels", "data_BME280", "data_envea"]
tables_to_clean = ["data_NPM", "data_NPM_5channels", "data_BME280", "data_envea", "data_CO2"]
# Loop through each table and delete old data
for table in tables_to_clean: