You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Derek - do you have a guide on migrating from Flask-SQLAlchemy to using SQLService?
I'm trying to wrap my head around what needs to be done, how the standard pattern of delaying engine creation can/should be done. For example:
import flask
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
def create_app(testing=False):
app = flask.create_app(__name__, testing=testing)
with app.app_context():
db.init_app(app)
log.info("SQLAlchemy URI: %s", app.config['SQLALCHEMY_DATABASE_URI'])
from .api import api
...
Obviously the app context wouldn't be needed any longer. But the delayed connection is quite useful to handle production vs unit test configuration of the database.
The text was updated successfully, but these errors were encountered:
I actually have an example FlaskSQLService class that I showed in #3 which includes the late-binding approach for engine creation via the Flask extension proxy class.
It's not tested by me in any way so there may be bugs or edge cases that need to be addressed but that example should help you get started.
One day I may have enough time to formalize that example into a flask-sqlservice extension proper but until then, feel free to use it directly.
Hi Derek - do you have a guide on migrating from Flask-SQLAlchemy to using SQLService?
I'm trying to wrap my head around what needs to be done, how the standard pattern of delaying engine creation can/should be done. For example:
Obviously the app context wouldn't be needed any longer. But the delayed connection is quite useful to handle production vs unit test configuration of the database.
The text was updated successfully, but these errors were encountered: