
This commit includes: - Basic project structure with FastAPI - SQLite database integration using SQLAlchemy - CRUD API for items - Alembic migrations setup - Health check endpoint - Proper error handling - Updated README with setup instructions
38 lines
752 B
Python
38 lines
752 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class ItemBase(BaseModel):
|
|
"""Base schema for Item."""
|
|
name: str
|
|
description: Optional[str] = None
|
|
is_active: bool = True
|
|
|
|
|
|
class ItemCreate(ItemBase):
|
|
"""Schema for creating a new Item."""
|
|
pass
|
|
|
|
|
|
class ItemUpdate(BaseModel):
|
|
"""Schema for updating an Item."""
|
|
name: Optional[str] = None
|
|
description: Optional[str] = None
|
|
is_active: Optional[bool] = None
|
|
|
|
|
|
class ItemInDBBase(ItemBase):
|
|
"""Base schema for Item in DB."""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class Item(ItemInDBBase):
|
|
"""Schema for an Item."""
|
|
pass |