From 6b3c3d2b0e13baed5d60f4eb3e4b483b08096398 Mon Sep 17 00:00:00 2001 From: Michel Date: Sat, 26 Apr 2025 20:24:02 +0200 Subject: [PATCH] Ajout ou correction sur develop --- domo91.py | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/domo91.py b/domo91.py index c32c26a..c884351 100644 --- a/domo91.py +++ b/domo91.py @@ -1,7 +1,4 @@ -# Application Gestion de sondes # -*- coding: utf-8 -*- -from logging import exception - import streamlit as st import mysql.connector import pandas as pd @@ -514,25 +511,27 @@ if st.session_state["authenticated"]: except Exception as e: st.error(f"Erreur SQL (admin) : {e}") -# --- ONGLET TRAFFIC ------ - elif onglet == "Traffic": - st.markdown("## 🚦 Connexions récentes") - try: - conn = mysql.connector.connect(**db_config) - cursor = conn.cursor(dictionary=True) - cursor.execute( - "SELECT Utilisateur, Lieu, Date_Connexion FROM Connexion_Log ORDER BY Date_Connexion DESC LIMIT 200") - connexions = cursor.fetchall() - cursor.close() - conn.close() +# --- ONGLET TRAFFIC ------ +elif onglet == "Traffic": + st.markdown("## 🚦 Connexions récentes") + try: + conn = mysql.connector.connect(**db_config) + cursor = conn.cursor(dictionary=True) + cursor.execute( + "SELECT Utilisateur, Lieu, Date_Connexion FROM Connexion_Log WHERE Lieu IS NOT NULL ORDER BY Date_Connexion DESC LIMIT 200" + ) + connexions = cursor.fetchall() + cursor.close() + conn.close() - if connexions: - df_connexions = pd.DataFrame(connexions) - st.dataframe(df_connexions, use_container_width=True) - else: - st.info("Aucune connexion enregistrée.") - except Exception as e: - st.error(f"Erreur chargement des connexions : {e}") + if connexions: + df_connexions = pd.DataFrame(connexions) + st.success(f"{len(df_connexions)} connexions trouvées.") # Compteur affiché proprement + st.dataframe(df_connexions, use_container_width=True) + else: + st.info("Aucune connexion enregistrée.") + except Exception as e: + st.error(f"Erreur chargement des connexions : {e}") - except exception as err: - st.error(f"Erreur MySQL : {err}") \ No newline at end of file + except Exception as err: + st.error(f"Erreur MySQL : {err}") \ No newline at end of file