
- Create app/db/base.py with SQLAlchemy Base definition - Create app/db/session.py with database engine and session setup using absolute path /app/storage/db/db.sqlite - Create app/models/todo.py with Todo model including id, title, description, completed, created_at, updated_at fields - Create app/schemas/todo.py with Pydantic schemas for TodoCreate, TodoUpdate, and TodoResponse - Add necessary __init__.py files for proper package structure
26 lines
528 B
Python
26 lines
528 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class TodoCreate(BaseModel):
|
|
title: str
|
|
description: Optional[str] = None
|
|
|
|
|
|
class TodoUpdate(BaseModel):
|
|
title: Optional[str] = None
|
|
description: Optional[str] = None
|
|
completed: Optional[bool] = None
|
|
|
|
|
|
class TodoResponse(BaseModel):
|
|
id: int
|
|
title: str
|
|
description: Optional[str] = None
|
|
completed: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True |