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.
37 lines
953 B
37 lines
953 B
import sqlite3
|
|
|
|
conn = sqlite3.connect("iot_data.sqlite")
|
|
cursor = conn.cursor()
|
|
|
|
cursor.execute("""
|
|
CREATE TABLE IF NOT EXISTS mereni (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
cas TEXT NOT NULL,
|
|
teplota REAL NOT NULL,
|
|
vlhkost REAL NOT NULL
|
|
)
|
|
""")
|
|
conn.commit()
|
|
print("Tabulka mereni vytovřena (nebo již existuje).☺")
|
|
|
|
testovaci_data = [
|
|
("2026-03-18 08:00:00", 22.5,45.0),
|
|
("2026-03-18 08:05:00", 23.5,48.0),
|
|
("2026-03-18 08:10:00", 23.2,44.0),
|
|
("2026-03-18 08:15:00", 22.8,49.0),
|
|
("2026-03-18 08:20:00", 25.2,60.0),
|
|
]
|
|
cursor.executemany(
|
|
"INSERT INTO mereni (cas, teplota, vlhkost) VALUES (?, ?, ?)",
|
|
testovaci_data
|
|
)
|
|
conn.commit()
|
|
print(f"Vloženo {len(testovaci_data)} záznamů")
|
|
|
|
print("--- Všechna měření ---")
|
|
cursor.execute("SELECT * FROM mereni")
|
|
for radek in cursor.fetchall():
|
|
print(radek)
|
|
|
|
conn.close()
|
|
print("\nHotovo! Soubor iot_data.db vytvořen")
|