Adding Automatic Imports to the Flask Shell


Flask Tip:

Additional automatic imports can be added to the Flask shell using shell_context_processor().

👇

# ... After creating the Flask application (`app`) ...
@app.shell_context_processor
def shell_context():
    return {'database': database}


# in terminal
$ flask shell
>>> print(database)