Add SQLAlchemy and database boilerplate code

This commit is contained in:
Lexi / Zoe 2022-04-02 01:06:59 +02:00
parent 2da6e43797
commit 31df889dcb
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
15 changed files with 454 additions and 60 deletions

25
tofu_api/models/task.py Normal file
View file

@ -0,0 +1,25 @@
from sqlalchemy import Column, Integer, String, Text
from tofu_api.common.database import Model
class Task(Model):
"""
Database model for tasks.
"""
__tablename__ = 'tasks'
id: int = Column(Integer, nullable=False, primary_key=True)
# TODO: created_at, modified_at
title: str = Column(String(255), nullable=False)
description: str = Column(Text, nullable=False, default='')
def to_dict(self) -> dict:
# TODO: Implement a generic to_dict() in the base model
return {
'id': self.id,
'title': self.title,
'description': self.description,
}