Flask mongoengine connect through uri
flask, heroku, mongodb, mongoengine
Solution
So I got it working (finally):
from flask import Flask
from mongoengine import connect
app = Flask(__name__)
app.config["MONGODB_DB"] = 'app12345678'
connect(
'app12345678',
username='heroku',
password='a614e68b445d0d9d1c375740781073b4',
host='mongodb://<user>:<password>@alex.mongohq.com:10043/app12345678',
port=10043
)
Though I anticipate that various other configurations will work.
Problem
I have a small flask application which I am deploying to Heroku. My local configuration looks like this: ``` from flask import Flask from flask.ext.mongoengine import MongoEngine app = Flask(__name__) app.debug = True app.config["MONGODB_SETTINGS"] = {'DB': "my_app"} app.config["SECRET_KEY"] = "secretpassword" db = MongoEngine(app) ``` So, I know that I need to configure the app to use the Mongo `URI` method of connection, and I have my connection info: ``` mongodb://<user>:<password>@alex.mongohq.com:10043/app12345678 ``` I am just a little stuck as to the syntax for modifying my app to connect through the `URI`.