I have associated multiple engines with a SQLAlchemy Object. To use sessionmaker to create sessions I need to get the right engine. When I try db.engine (db is my SQLAlchemy object), I get the default engine. How do I get the other associated engines? I would prefer if I could give a key and get the right engine.
I used Flask's SQLALCHEMY_BINDS to associate more than one engine.
Use db.get_engine(bind='my_bind_key'). db.engine is just a shortcut to this for the default bind. However, you should not need to set up sessions yourself, Flask-SQLAlchemy already has all the parts in place to use the correct bind when using db.session.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With