
- Created FastAPI application with SQLite database - Implemented models for inventory items, categories, suppliers, and transactions - Added authentication system with JWT tokens - Implemented CRUD operations for all models - Set up Alembic for database migrations - Added comprehensive API documentation - Configured Ruff for code linting
21 lines
574 B
Python
21 lines
574 B
Python
from typing import Optional
|
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.crud.base import CRUDBase
|
|
from app.models.category import Category
|
|
from app.schemas.category import CategoryCreate, CategoryUpdate
|
|
|
|
|
|
class CRUDCategory(CRUDBase[Category, CategoryCreate, CategoryUpdate]):
|
|
"""
|
|
CRUD operations for Category model.
|
|
"""
|
|
def get_by_name(self, db: Session, *, name: str) -> Optional[Category]:
|
|
"""
|
|
Get a category by name.
|
|
"""
|
|
return db.query(Category).filter(Category.name == name).first()
|
|
|
|
|
|
category = CRUDCategory(Category) |