I'm trying to follow the Flask-User documentation with MongoDB.
However, when I try to connect to my MongoDB Atlas, it's always writing to a "test" database, instead of the one I specify.
I have identified that it is because of the Flask-MongoEngine that is being used, as it mentions that
By default, Flask-MongoEngine assumes that the mongod instance is running on localhost on port 27017, and you wish to connect to the database named test.
However, even after inputting my URI details, I still keep writing to the test database.
Uri style connections are also supported, just supply the uri as the hostin the ‘MONGODB_SETTINGS’ dictionary with app.config. Note that database name from uri has priority over name.
app.config['MONGODB_SETTINGS'] = { 'db': 'project1', 'host': 'mongodb://localhost/database_name' }
My code
My configuration settings (albeit in another syntax) are as below
app.config['MONGODB_DB'] = '<redcated-database-name>'
app.config['MONGODB_HOST'] = 'mongodb+srv://<redcated-user>:<redcated-pw>@gapcluster-np4bu.mongodb.net/test?retryWrites=true&w=majority'
app.config['MONGODB_PORT'] = 27017
app.config["MONGODB_CONNECTION"] = False
Has anyone successfully used Flask-User with MongoDB Atlas before?