Ajout ou correction sur develop

This commit is contained in:
2025-04-26 20:24:02 +02:00
parent 182fd09e53
commit 6b3c3d2b0e

View File

@@ -1,7 +1,4 @@
# Application Gestion de sondes
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from logging import exception
import streamlit as st import streamlit as st
import mysql.connector import mysql.connector
import pandas as pd import pandas as pd
@@ -514,25 +511,27 @@ if st.session_state["authenticated"]:
except Exception as e: except Exception as e:
st.error(f"Erreur SQL (admin) : {e}") st.error(f"Erreur SQL (admin) : {e}")
# --- ONGLET TRAFFIC ------ # --- ONGLET TRAFFIC ------
elif onglet == "Traffic": elif onglet == "Traffic":
st.markdown("## 🚦 Connexions récentes") st.markdown("## 🚦 Connexions récentes")
try: try:
conn = mysql.connector.connect(**db_config) conn = mysql.connector.connect(**db_config)
cursor = conn.cursor(dictionary=True) cursor = conn.cursor(dictionary=True)
cursor.execute( cursor.execute(
"SELECT Utilisateur, Lieu, Date_Connexion FROM Connexion_Log ORDER BY Date_Connexion DESC LIMIT 200") "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() connexions = cursor.fetchall()
conn.close() cursor.close()
conn.close()
if connexions: if connexions:
df_connexions = pd.DataFrame(connexions) df_connexions = pd.DataFrame(connexions)
st.dataframe(df_connexions, use_container_width=True) st.success(f"{len(df_connexions)} connexions trouvées.") # Compteur affiché proprement
else: st.dataframe(df_connexions, use_container_width=True)
st.info("Aucune connexion enregistrée.") else:
except Exception as e: st.info("Aucune connexion enregistrée.")
st.error(f"Erreur chargement des connexions : {e}") except Exception as e:
st.error(f"Erreur chargement des connexions : {e}")
except exception as err: except Exception as err:
st.error(f"Erreur MySQL : {err}") st.error(f"Erreur MySQL : {err}")