-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
46 lines (34 loc) · 1.14 KB
/
main.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
37
38
39
40
41
42
43
44
45
46
from typing import Dict
from sqlmodel import Sequence, Session, create_engine, select
from models import Patient, Question
def load_patients(sqlite_name: str = "database.sqlite") -> Sequence[Patient]:
sqlite_db = sqlite_name
sqlite_url = f"sqlite:///{sqlite_db}"
engine = create_engine(sqlite_url)
session = Session(engine)
query_for_patient = select(Patient)
patients = session.exec(query_for_patient).all()
session.close()
return patients
def add_symptom(data: Dict, sqlite_name: str = "database.sqlite"):
sqlite_db = sqlite_name
sqlite_url = f"sqlite:///{sqlite_db}"
engine = create_engine(sqlite_url)
session = Session(engine)
new_question = Question(**data)
session.add(new_question)
session.commit()
session.close()
if __name__ == "__main__":
add_symptom(
{
"symptom": "test",
"category": "Medical history",
"subcategory": "Cervical Cancer Screening",
"question": "test",
"question_korean": "test",
"is_relevant": False,
"source": "test",
"labeler": "test",
}
)