louiecerv commited on
Commit
6607494
·
1 Parent(s): 03dba14
Files changed (2) hide show
  1. monitor.py +43 -0
  2. users.db +0 -0
monitor.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import sqlite3
3
+ import pandas as pd
4
+
5
+ # Connect to the database
6
+ conn = sqlite3.connect('users.db')
7
+ c = conn.cursor()
8
+
9
+ # Create a function to retrieve user prompts from the database
10
+ def get_user_prompts(username=None):
11
+ if username:
12
+ c.execute('SELECT * FROM user_prompts WHERE username=?', (username,))
13
+ else:
14
+ c.execute('SELECT * FROM user_prompts')
15
+ user_prompts = c.fetchall()
16
+ return user_prompts
17
+
18
+ # Create a function to convert user prompts to a Pandas DataFrame
19
+ def user_prompts_to_df(user_prompts):
20
+ df = pd.DataFrame(user_prompts, columns=['id', 'username', 'prompt_time', 'prompt_type'])
21
+ return df
22
+
23
+ # Create a Streamlit page
24
+ st.title("User Prompts Summary")
25
+
26
+ # Retrieve all usernames from the database
27
+ c.execute('SELECT username FROM userstable')
28
+ usernames = [row[0] for row in c.fetchall()]
29
+
30
+ # Add a selectbox to filter user prompts by username
31
+ username_filter = st.selectbox("Filter by username", ["All"] + usernames)
32
+
33
+ # Retrieve user prompts based on the selected username
34
+ if username_filter == "All":
35
+ user_prompts = get_user_prompts()
36
+ else:
37
+ user_prompts = get_user_prompts(username_filter)
38
+
39
+ # Convert user prompts to a Pandas DataFrame
40
+ df = user_prompts_to_df(user_prompts)
41
+
42
+ # Display the DataFrame
43
+ st.write(df)
users.db CHANGED
Binary files a/users.db and b/users.db differ