File size: 615 Bytes
a188e11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from db import get_connection

def save_history(user_id, symptoms, diagnosis):
    with get_connection() as conn, conn.cursor() as cur:
        cur.execute("INSERT INTO mb_history (user_id, symptoms, diagnosis) VALUES (%s, %s, %s)",
                    (user_id, symptoms, diagnosis))
        conn.commit()

def get_history(user_id):
    with get_connection() as conn, conn.cursor() as cur:
        cur.execute("""
            SELECT timestamp, symptoms, diagnosis
            FROM mb_history
            WHERE user_id = %s
            ORDER BY timestamp DESC
        """, (user_id,))
        return cur.fetchall()