15 lines
401 B
Python
15 lines
401 B
Python
from typing import Any
|
|
|
|
from sqlalchemy.ext.declarative import declared_attr
|
|
from sqlalchemy.orm import DeclarativeBase
|
|
|
|
|
|
class Base(DeclarativeBase):
|
|
"""Base class for all SQLAlchemy database models."""
|
|
|
|
id: Any
|
|
|
|
@declared_attr.directive
|
|
def __tablename__(cls) -> str:
|
|
"""Generate __tablename__ automatically from the class name."""
|
|
return cls.__name__.lower() |