This commit is contained in:
Your Name
2025-02-20 15:30:34 +01:00
parent d5f1acc025
commit 725ee971c7
38 changed files with 405 additions and 84 deletions

33
sqlite/write.py Normal file
View File

@@ -0,0 +1,33 @@
'''
____ ___ _ _ _
/ ___| / _ \| | (_) |_ ___
\___ \| | | | | | | __/ _ \
___) | |_| | |___| | || __/
|____/ \__\_\_____|_|\__\___|
Script to write data to a sqlite database
/usr/bin/python3 /var/www/moduleair_pro_4g/sqlite/write.py
'''
import sqlite3
# Connect to the SQLite database
conn = sqlite3.connect("/var/www/moduleair_pro_4g/sqlite/sensors.db")
cursor = conn.cursor()
# Insert a sample temperature reading
timestamp = "2025-10-11"
PM1 = 25.3
PM25 = 18.3
PM10 = 9.3
cursor.execute('''
INSERT INTO data (timestamp, PM1, PM25, PM10) VALUES (?,?,?,?,?)'''
, (timestamp,PM1,PM25,PM10))
# Commit and close the connection
conn.commit()
conn.close()
print("Sensor data saved successfully!")