I want to access my azure cosmosDB database using flask-mongoengine library.
I've tried to pass host uri in app.config['MONGODB_HOST'] but it's returning empty list from DB collections.
db= MongoEngine()
app.config['MONGODB_DB'] = 'DB_NAME'
app.config['MONGODB_HOST'] = 'mongodb://<username>:<password>@host:port/?ssl=true&replicaSet=replicaSetName'
db.init_app(app)
app.run(port=4001, debug=True)
While printing UserModel.objects(username=username) it shows empty list.
P.S. My db has UserModel which store username and passwords of the users.
I was able to solve it by passing the database_name in the URI instead of passing it in app.config
Following worked for me:
app.config['MONGODB_HOST'] = 'mongodb://<username>:<password>@host:port/DB_NAME?ssl=true&replicaSet=replicaSetName'