
- Set up project structure with FastAPI and dependency files - Configure SQLAlchemy with SQLite database - Implement user authentication using JWT tokens - Create comprehensive API routes for user management - Add health check endpoint for application monitoring - Set up Alembic for database migrations - Add detailed documentation in README.md
26 lines
693 B
Python
26 lines
693 B
Python
from sqlalchemy.ext.declarative import declared_attr
|
|
from sqlalchemy import Column, Integer, DateTime
|
|
from datetime import datetime
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class BaseModel(Base):
|
|
"""
|
|
Base model class that includes common fields and functionality
|
|
for all models.
|
|
"""
|
|
|
|
__abstract__ = True
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
@declared_attr
|
|
def __tablename__(cls) -> str:
|
|
"""
|
|
Generate table name automatically from the class name.
|
|
"""
|
|
return cls.__name__.lower()
|