Spaces:
Sleeping
Sleeping
| # crud.py | |
| from sqlalchemy.orm import Session | |
| from models import Patient | |
| from schemas import PatientCreate | |
| def create_patient(db: Session, data: PatientCreate): | |
| patient = Patient(**data.dict()) | |
| db.add(patient) | |
| db.commit() | |
| db.refresh(patient) | |
| return patient | |
| def get_patients(db: Session): | |
| return db.query(Patient).all() | |
| def get_patient(db: Session, patient_id: int): | |
| return db.query(Patient).filter(Patient.id == patient_id).first() |