Skip to content
Snippets Groups Projects
Select Git revision
  • 1665a5a3bf344371a97dbd4efa60d7762f005799
  • master default
2 results

test.py

Blame
  • 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