[Flask] Flask connect different mongodb according to situation sequence

Chenyang Yan memory.yancy at gmail.com
Tue Nov 20 12:47:28 EST 2018

Anyone have a good idea about connecting different mongodb in Flask
according to situation sequence? Thanks in advanced !

database-A will be connected in flask app001.init_app() using
pymodm.connect(), and then I can do CRUD operation. But database-B
will be installed latter.
That is, I use database-A record related info about installing other
system app env(such as: install docker, k8s ... create another flask
env named SKYAPP and start database-B to use)

How to connect database-B in app001 using one better way or other
idea? I googled and find one, but this method is not perfect in some
way. Everytime need connect when request API:

# when other sysyem finished installing, get database-B IP, port from
installed system app
class UserView(FlaskView):
    from pymodm import connect
database-B_port)    # since will install system app env, so database-B
related info can not hardcode

More information about the Flask mailing list