Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
1from __future__ import annotations2 3import typing as t4 5from flask import current_app6 7 8def add_models_to_shell() -> dict[str, t.Any]:9    """Registered with :meth:`~flask.Flask.shell_context_processor` if10    ``add_models_to_shell`` is enabled. Adds the ``db`` instance and all model classes11    to ``flask shell``.12    """13    db = current_app.extensions["sqlalchemy"]14    out = {m.class_.__name__: m.class_ for m in db.Model._sa_registry.mappers}15    out["db"] = db16    return out17 
codekingpro/portable-devtools · Team Ai