Ajout foctions dans l'app

This commit is contained in:
2025-06-01 09:54:35 +02:00
parent 45c4c3756c
commit b3c70abb6a
3 changed files with 156 additions and 9 deletions

View File

@@ -4,6 +4,42 @@ from dotenv import load_dotenv
load_dotenv()
def lire_alertes_sondes():
conn = None
cursor = None
try:
conn = get_connection()
cursor = conn.cursor(dictionary=True)
cursor.execute("SELECT * FROM Alertes_Chaufferie ORDER BY Debut_defaut DESC")
return cursor.fetchall()
except Exception as e:
import streamlit as st
st.warning(f"Erreur lecture alertes : {e}")
return []
finally:
if cursor:
cursor.close()
if conn and conn.is_connected():
conn.close()
def acquitter_alerte(id_alerte):
conn = None
cursor = None
try:
conn = get_connection()
cursor = conn.cursor()
cursor.execute("UPDATE Alertes_Chaufferie SET Etat = 'Acquitté' WHERE Id = %s", (id_alerte,))
conn.commit()
except Exception as e:
import streamlit as st
st.warning(f"Erreur lors de l'acquittement : {e}")
finally:
if cursor:
cursor.close()
if conn and conn.is_connected():
conn.close()
def verifier_utilisateur_commun(login, password):
conn = get_connection()
cursor = conn.cursor(dictionary=True)