[Python] RuntimeError: Working outside of application context

Discussão em 'Python' iniciado por Stack, Setembro 6, 2025.

  1. Stack

    Stack Membro Participativo

    Error File "C:\Users\shrav\AppData\Local\Programs\Python\Python313\Lib\site-packages\flask_sqlalchemy\extension.py", line 900, in create_all self._call_for_binds(bind_key, "create_all") ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\shrav\AppData\Local\Programs\Python\Python313\Lib\site-packages\flask_sqlalchemy\extension.py", line 871, in _call_for_binds engine = self.engines[key] ^^^^^^^^^^^^ File "C:\Users\shrav\AppData\Local\Programs\Python\Python313\Lib\site-packages\flask_sqlalchemy\extension.py", line 687, in engines app = current_app._get_current_object() # type: ignore[attr-defined] File "C:\Users\shrav\AppData\Local\Programs\Python\Python313\Lib\site-packages\werkzeug\local.py", line 519, in _get_current_object raise RuntimeError(unbound_message) from None RuntimeError: Working outside of application context.

    This typically means that you attempted to use functionality that needed the current application. To solve this, set up an application context with app.app_context(). See the documentation for more information.

    Continue reading...

Compartilhe esta Página