-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneral_testing.py
36 lines (28 loc) · 1.05 KB
/
general_testing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sqlite3
from datetime import datetime
import pandas as pd
from patient_test import Patient
# "DB data processing" testing
def convert_timestamp(timestamp):
# Convert the timestamp to a readable format
if not timestamp:
return None
dt_object = datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S.%f')
return dt_object.date().strftime("%d/%m/%Y")
conn = sqlite3.connect('instance/database.db')
data = pd.read_sql_query("SELECT * from Patient", conn)
conn.close()
data['timestamp'] = data['timestamp'].apply(convert_timestamp)
counters = data['people_counter'].groupby(data['timestamp']).count().tolist()
dates = data['timestamp'].unique()
dates = pd.Series(dates).dropna().tolist()
# "fetching user data from db" testing
conn = sqlite3.connect('testing_database.db', timeout=15)
cur = conn.cursor()
cur.execute("SELECT * FROM user WHERE role = 'User' ORDER BY id DESC")
last_user = cur.fetchone()
conn.close()
pat = Patient(patient_id=last_user[0], name=last_user[3])
pat.load()
# print all the attributes of the patient
print(pat.__dict__)