Search code examples
pythonflaskscalable

importing flask models into python console in a scalable architecture


i have have the following folder structure for a simple flask-app.

Folder structure

with a one-page structure i was able to import models in python console, but since i changed the structure to a scalable model, i cant seem to find a way to import models into my python console, i get this error.

RuntimeError: application not registered on db instance and no application bound to current context

is there a workaround for this ?


Solution

  • You need to be running in an application context. Use the flask shell command to set this up for you.

    FLASK_APP=app flask shell
    

    Or set it up manually:

    >>> from app import app
    >>> app.app_context().push()