'''
  ____   ___  _     _ _       
 / ___| / _ \| |   (_) |_ ___ 
 \___ \| | | | |   | | __/ _ \
  ___) | |_| | |___| | ||  __/
 |____/ \__\_\_____|_|\__\___|
                              
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!")
