nathan-rice/flask-sqlalchemy — comment on commit 22b2e17b08c7e2752ce8dc2191c5688e2a9ca8f3
File:  line 0
By benluo:

I did another way to de-couple without any patch.

in models.py,

db = SQLAlchemy()

in app.py
app = Flask(__name__)
db.init_app(app)
app.config.from_object(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE
app.test_request_context().push()

I don't know the exact funtion of app.test_request_context().push(). But it works.

Do you know the reason?