This commit is contained in:
Your Name
2025-05-23 15:09:22 +02:00
parent 5a1a4e0d81
commit 020594e065
6 changed files with 277 additions and 59 deletions

View File

@@ -20,10 +20,8 @@ cursor = conn.cursor()
print(f"Connected to database")
# Clear existing data (if any)
cursor.execute("DELETE FROM config_table")
cursor.execute("DELETE FROM envea_sondes_table")
print("Existing data cleared")
# Note: Using INSERT OR IGNORE to add only new configurations without overwriting existing ones
print("Adding new configurations (existing ones will be preserved)")
# Insert general configurations
@@ -54,7 +52,7 @@ config_entries = [
for key, value, value_type in config_entries:
cursor.execute(
"INSERT INTO config_table (key, value, type) VALUES (?, ?, ?)",
"INSERT OR IGNORE INTO config_table (key, value, type) VALUES (?, ?, ?)",
(key, value, value_type)
)
@@ -67,7 +65,7 @@ envea_sondes = [
for connected, port, name, coefficient in envea_sondes:
cursor.execute(
"INSERT INTO envea_sondes_table (connected, port, name, coefficient) VALUES (?, ?, ?, ?)",
"INSERT OR IGNORE INTO envea_sondes_table (connected, port, name, coefficient) VALUES (?, ?, ?, ?)",
(1 if connected else 0, port, name, coefficient)
)