openedoo / module_employee

MIT License
0 stars 0 forks source link

SQLAlchemy and Flask application context #3

Open ghost opened 7 years ago

ghost commented 7 years ago

I get some issue with managing multiple SQLAlchemy db schema on my models when migration. I think, this is because of the flask application factory and application context design, referred from http://piotr.banaszkiewicz.org/blog/2012/06/29/flask-sqlalchemy-init_app/ .

Flask-SQLAlchemy has two usage modes.

Option 1

Binding the instance to a very specific Flask application

app = Flask(__name__)
db = SQLAlchemy(app)

Option 2

Create the object once and configure the application later to support it

db = SQLAlchemy()

def create_app():
    app = Flask(__name__)
    db.init_app(app)
    return app

The Openedoo core uses option 1, change the core to option 2 to help you make models migration in this module.

suggestions are welcome.

rendiya commented 7 years ago

yah di note dulu, antara rubah core atau module

ghost commented 7 years ago

yup, ini sebagai clue aja jika ada yang mau mencoba module ini.