base_class.py 289 B

1234567891011121314
  1. from typing import Any
  2. from sqlalchemy.ext.declarative import as_declarative, declared_attr
  3. @as_declarative()
  4. class Base:
  5. id: Any
  6. __name__: str
  7. # Generate __tablename__ automatically
  8. @declared_attr
  9. def __tablename__(cls) -> str:
  10. return cls.__name__.lower()