
- Created app directory structure with db, models, and schemas modules - Added SQLAlchemy Base class in app/db/base.py to prevent circular imports - Implemented database session setup with SQLite configuration - Created Todo model with id, title, description, completed, created_at, updated_at fields - Added Pydantic schemas for TodoCreate, TodoUpdate, and TodoResponse - Added requirements.txt with FastAPI, SQLAlchemy, and other dependencies
28 lines
511 B
Python
28 lines
511 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class TodoBase(BaseModel):
|
|
title: str
|
|
description: Optional[str] = None
|
|
|
|
|
|
class TodoCreate(TodoBase):
|
|
pass
|
|
|
|
|
|
class TodoUpdate(BaseModel):
|
|
title: Optional[str] = None
|
|
description: Optional[str] = None
|
|
completed: Optional[bool] = None
|
|
|
|
|
|
class TodoResponse(TodoBase):
|
|
id: int
|
|
completed: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True |