todoapi-0h1oi4/app/db/base_class.py
Automated Action 7fa5fb0213 Setup complete Todo API with FastAPI and SQLite
- Create Todo model and schemas
- Set up API endpoints for CRUD operations
- Configure SQLAlchemy for database access
- Set up Alembic for database migrations
- Add Ruff for code linting
- Update README with project documentation
2025-05-27 06:32:35 +00:00

23 lines
465 B
Python

"""
Base class for SQLAlchemy models.
"""
from typing import Any
from sqlalchemy.ext.declarative import as_declarative, declared_attr
@as_declarative()
class Base:
"""
Base class for all SQLAlchemy models.
"""
id: Any
__name__: str
# Generate __tablename__ automatically
@declared_attr
def __tablename__(cls) -> str:
"""
Generate table name based on the class name.
"""
return cls.__name__.lower()