Automated Action 4bbc49f04d Create a FastAPI REST API service with SQLite database
- Set up project structure
- Configure SQLite database with SQLAlchemy
- Create item model and schema
- Set up Alembic for database migrations
- Implement CRUD operations for items
- Add health check endpoint
- Add API documentation
- Configure Ruff for linting
- Update README with project information
2025-05-23 09:14:12 +00:00

42 lines
969 B
Python

from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field
# Shared properties
class ItemBase(BaseModel):
title: str = Field(..., title="Item title", max_length=255)
description: Optional[str] = Field(None, title="Item description")
is_active: Optional[bool] = Field(True, title="Item is active")
# Properties to receive on item creation
class ItemCreate(ItemBase):
pass
# Properties to receive on item update
class ItemUpdate(ItemBase):
title: Optional[str] = Field(None, title="Item title", max_length=255)
is_active: Optional[bool] = Field(None, title="Item is active")
# Properties shared by models returned from API
class ItemInDBBase(ItemBase):
id: int
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True
# Properties to return to client
class Item(ItemInDBBase):
pass
# Properties stored in DB
class ItemInDB(ItemInDBBase):
pass