Skip to main content

hook_base_model

FunctionPrivateSource

hooked_model: type[_Model_contra] = hook_base_model[_Model_contra](
cls: type[_Model_contra],
db: SQLAlchemyProtocol | SQLAlchemyLiteProtocol,
)

Add hooks to the given Model class. This hook will synthesize the __tablename__, query and query_cls properties if any of them is not specified in the subclass.

Arguments

Requires

ArgumentTypeRequired
Description
clstype[_Model_contra]The class to be hooked.
dbflask_sqlalchemy.SQLAlchemy | flask_sqlalchemy_lite.SQLAlchemyThe db instance used for providing the session.
  • where _Model_contra is a TypeVar of DeclarativeBase | DeclarativeBaseNoMeta.

Returns

ArgumentType
Description
hooked_modeltype[_Model_contra]The hooked base model class.