summaryrefslogtreecommitdiff
path: root/src/db_handler.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/db_handler.py')
-rw-r--r--src/db_handler.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/db_handler.py b/src/db_handler.py
index 7766da1..d607aee 100644
--- a/src/db_handler.py
+++ b/src/db_handler.py
@@ -54,3 +54,18 @@ LIMIT 1;
password = cur.fetchone()['password']
return password
+
+
+def get_histogram() -> str:
+ with psycopg.connect(**db_con_params, row_factory=psycopg.rows.dict_row) as conn:
+ with conn.cursor() as cur:
+ cur.execute("""
+SELECT count(id) as total_count, date_trunc('hour', timestamp) as date
+FROM login_attempt
+GROUP BY date_trunc('hour', timestamp)
+ORDER BY date_trunc('hour', timestamp)
+LIMIT 48
+;
+ """)
+ histogram = cur.fetchall()
+ return histogram