2025-11-26 21:11:12 +08:00
|
|
|
from sqlalchemy.orm import as_declarative, declared_attr
|
|
|
|
|
|
|
|
|
|
@as_declarative()
|
|
|
|
|
class Base:
|
|
|
|
|
id: str
|
|
|
|
|
__name__: str
|
|
|
|
|
|
|
|
|
|
# Generate __tablename__ automatically
|
|
|
|
|
@declared_attr
|
|
|
|
|
def __tablename__(cls) -> str:
|
|
|
|
|
return cls.__name__.lower() + "s"
|
|
|
|
|
|
2025-11-27 18:01:57 +08:00
|
|
|
|
2025-12-11 19:09:10 +08:00
|
|
|
|