todoapi-f42fit/app/db/base_class.py
Automated Action 53566813bd Complete Todo API implementation with FastAPI and SQLite
- Add SQLite database configuration
- Create Todo model, schemas, and CRUD operations
- Implement Todo API endpoints
- Add Alembic migration for todo table
- Set up database initialization in main.py
- Update README with project details and instructions
- Add pyproject.toml with Ruff configuration
2025-06-10 15:40:42 +00:00

15 lines
502 B
Python

from datetime import datetime
from sqlalchemy import Column, DateTime
from sqlalchemy.ext.declarative import declared_attr
class BaseClass:
# Generate __tablename__ automatically based on class name
@declared_attr
def __tablename__(cls) -> str:
return cls.__name__.lower()
# Add created_at and updated_at columns to all models
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)