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

26 lines
710 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_multi_by_active(
self, db: Session, *, active: bool, skip: int = 0, limit: int = 100
) -> List[Item]:
return (
db.query(Item)
.filter(Item.is_active == active)
.offset(skip)
.limit(limit)
.all()
)
item = CRUDItem(Item)