From dd087359022fc8c6b8ab2af46f9f4a9f40673c99 Mon Sep 17 00:00:00 2001 From: Michel Date: Sat, 19 Apr 2025 09:02:18 +0200 Subject: [PATCH] =?UTF-8?q?Conflit=20readme=20r=C3=A8gl=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- domo91.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/domo91.py b/domo91.py index 6df5cd9..5a443ce 100644 --- a/domo91.py +++ b/domo91.py @@ -8,6 +8,7 @@ import matplotlib.dates as mdates from fpdf import FPDF import os import random +import datetime st.set_page_config(page_title="Domo91 - Surveillance", layout="wide") st.title("📡 Supervision Températures") @@ -19,6 +20,8 @@ db_config = { "password": "#SO2&1nf%mZ@jfh", "database": "Sondes" } + + # --- Fonction de génération PDF --- def generer_pdf(site, date_str): st.info(f"Génération du rapport PDF pour {site} à la date {date_str}") @@ -105,6 +108,23 @@ if "authenticated" not in st.session_state: # --- Sidebar (connexion + bouton PDF) --- with st.sidebar: + if st.sidebar.button("🔔 Forcer une alerte de test"): + now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + sonde_test = "TEST_ALERTE" + try: + conn = mysql.connector.connect(**db_params) + cursor = conn.cursor() + table_alertes = f"Alertes_{site}" + cursor.execute(f""" + INSERT INTO {table_alertes} (Sonde, Debut_defaut, Etat) + VALUES (%s, %s, %s) + """, (sonde_test, now, "Test")) + conn.commit() + cursor.close() + conn.close() + st.success(f"Alerte de test créée pour {sonde_test} à {now}") + except Exception as e: + st.error(f"Erreur lors de la création de l'alerte : {e}") st.header("🔐 Connexion") if not st.session_state.get("authenticated"): login = st.text_input("Nom d'utilisateur")