Select Git revision
Forked from
Automatants / Facial expression detection
Source project has a limited visibility.
crud.py NaN GiB
"""
Module to interact with the database
"""
from sqlalchemy.orm import Session
from db import models, schemas
def get_records(place: str, db: Session):
""" Get all the records for the given place """
records = db.query(models.Records).filter(models.Records.place == place).order_by(models.Records.date.desc()).all()
return records
def create_record(new_record: schemas.RecordBase, db: Session):
""" Add a new record to the database """
db_record = models.Records(**new_record.dict())
db.add(db_record)
db.commit()
db.refresh(db_record)
return db_record