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 -*-
|
# -*- 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
|
||||||
@@ -515,24 +512,26 @@ if st.session_state["authenticated"]:
|
|||||||
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()
|
connexions = cursor.fetchall()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
if connexions:
|
if connexions:
|
||||||
df_connexions = pd.DataFrame(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)
|
st.dataframe(df_connexions, use_container_width=True)
|
||||||
else:
|
else:
|
||||||
st.info("Aucune connexion enregistrée.")
|
st.info("Aucune connexion enregistrée.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
st.error(f"Erreur chargement des connexions : {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}")
|
||||||
Reference in New Issue
Block a user