- @classmethod
- def by_date(cls, db_conn: DatabaseConnection,
- date: str, create: bool = False) -> Day:
- """Retrieve Day by date if in DB, else return None."""
- for row in db_conn.exec('SELECT * FROM days WHERE date = ?', (date,)):
- return cls.from_table_row(row)
- if not create:
- raise NotFoundException(f'Day not found for date: {date}')
- return cls(date)