Ajout ou correction sur develop
This commit is contained in:
11
domo91.py
11
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
|
||||
@@ -515,24 +512,26 @@ if st.session_state["authenticated"]:
|
||||
st.error(f"Erreur SQL (admin) : {e}")
|
||||
|
||||
# --- ONGLET TRAFFIC ------
|
||||
elif 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")
|
||||
"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.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:
|
||||
except Exception as err:
|
||||
st.error(f"Erreur MySQL : {err}")
|
||||
Reference in New Issue
Block a user