24 lines
539 B
Python
24 lines
539 B
Python
'''
|
|
Script to write data to a sqlite database
|
|
/usr/bin/python3 /var/www/nebuleair_pro_4g/sqlite/write.py
|
|
|
|
'''
|
|
|
|
import sqlite3
|
|
|
|
# Connect to the SQLite database
|
|
conn = sqlite3.connect("/var/www/nebuleair_pro_4g/sqlite/sensors.db")
|
|
cursor = conn.cursor()
|
|
|
|
# Insert a sample temperature reading
|
|
sensor_name = "temperature"
|
|
sensor_value = 25.3
|
|
|
|
cursor.execute("INSERT INTO data (sensor, value) VALUES (?, ?)", (sensor_name, sensor_value))
|
|
|
|
# Commit and close the connection
|
|
conn.commit()
|
|
conn.close()
|
|
|
|
print("Sensor data saved successfully!")
|