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 -*-
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}")
except Exception as err:
st.error(f"Erreur MySQL : {err}")