Automated Action 938b6d4153 Create a simple generic REST API with FastAPI and SQLite
Implemented a complete FastAPI backend with:
- Project structure with FastAPI and SQLAlchemy
- SQLite database with proper configuration
- Alembic for database migrations
- Generic Item resource with CRUD operations
- REST API endpoints with proper validation
- Health check endpoint
- Documentation and setup instructions
2025-05-17 20:57:23 +00:00

21 lines
608 B
Python

from typing import List, Optional
from sqlalchemy.orm import Session
from app.crud.base import CRUDBase
from app.models.item import Item
from app.schemas.item import ItemCreate, ItemUpdate
class CRUDItem(CRUDBase[Item, ItemCreate, ItemUpdate]):
def get_by_title(self, db: Session, *, title: str) -> Optional[Item]:
return db.query(Item).filter(Item.title == title).first()
def get_active_items(
self, db: Session, *, skip: int = 0, limit: int = 100
) -> List[Item]:
return db.query(Item).filter(Item.is_active).offset(skip).limit(limit).all()
item = CRUDItem(Item)