Files
nebuleair_pro_4g/sqlite/read.py
PaulVua d732f3ad2d update
2025-01-30 17:24:47 +01:00

24 lines
490 B
Python

'''
Script to read data from a sqlite database
/usr/bin/python3 /var/www/nebuleair_pro_4g/sqlite/read.py
'''
import sqlite3
# Connect to the SQLite database
conn = sqlite3.connect("/var/www/nebuleair_pro_4g/sqlite/sensors.db")
cursor = conn.cursor()
# Retrieve the last 10 sensor readings
cursor.execute("SELECT * FROM data ORDER BY timestamp DESC LIMIT 10")
rows = cursor.fetchall()
# Display the results
for row in rows:
print(row)
# Close the database connection
conn.close()