You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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()