Refonte des boutons 'Consulter la base de donnée': ils ouvrent désormais un grand modal Bootstrap (modal-xl scrollable) avec pagination 20 lignes/page (Précédent/Suivant + indicateur de plage). Le dropdown 'Nombre de mesures' est supprimé. Ajout des boutons Senseair S88 dans les 3 cartes pointant sur data_S88, et renommage du bouton MH-Z19 pour le distinguer. Backend: sqlite/read.py accepte un OFFSET optionnel (3e argument, défaut 0) et launcher.php endpoint table_mesure transmet ?offset=N. Rétrocompatible. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
53 lines
1.3 KiB
Python
Executable File
53 lines
1.3 KiB
Python
Executable File
'''
|
|
____ ___ _ _ _
|
|
/ ___| / _ \| | (_) |_ ___
|
|
\___ \| | | | | | | __/ _ \
|
|
___) | |_| | |___| | || __/
|
|
|____/ \__\_\_____|_|\__\___|
|
|
|
|
Script to read data from a sqlite database
|
|
/usr/bin/python3 /var/www/nebuleair_pro_4g/sqlite/read.py data_NPM 10
|
|
|
|
Available table are
|
|
data_NPM
|
|
data_NPM_5channels
|
|
data_BME280
|
|
data_envea
|
|
timestamp_table
|
|
data_MPPT
|
|
data_WIND
|
|
|
|
'''
|
|
|
|
import sqlite3
|
|
import sys
|
|
parameter = sys.argv[1:] # Exclude the script name
|
|
#print("Parameters received:")
|
|
table_name=parameter[0]
|
|
limit_num=parameter[1]
|
|
offset_num=parameter[2] if len(parameter) > 2 else "0"
|
|
|
|
# Connect to the SQLite database
|
|
conn = sqlite3.connect("/var/www/nebuleair_pro_4g/sqlite/sensors.db")
|
|
cursor = conn.cursor()
|
|
|
|
# Retrieve the last sensor readings based on insertion order (ROWID)
|
|
# This ensures we get the most recently inserted data, regardless of timestamp value
|
|
if table_name == "timestamp_table":
|
|
cursor.execute("SELECT * FROM timestamp_table")
|
|
else:
|
|
# Order by ROWID DESC to get most recently inserted rows first
|
|
query = f"SELECT * FROM {table_name} ORDER BY ROWID DESC LIMIT ? OFFSET ?"
|
|
cursor.execute(query, (limit_num, offset_num))
|
|
|
|
rows = cursor.fetchall()
|
|
# Keep DESC order - most recently inserted data first
|
|
|
|
|
|
# Display the results
|
|
for row in rows:
|
|
print(row)
|
|
|
|
# Close the database connection
|
|
conn.close()
|