Open
Description
I am attempting to connect with a mongolab uri provided by heroku. I store it as an evironment variable.
MONGOLAB_URI="mongodb://heroku_tchBR549:[email protected]:57934/heroku_tchBR549"
In my config.py, I declare it like so:
MONGOALCHEMY_CONNECTION_STRING = os.environ["MONGOLAB_URI"]
... whch results in the following:
File "/home/clownshoes/project/venv/local/lib/python2.7/site-packages/flask_mongoalchemy/__init__.py", line 116, in init_app
"(the %s setting)." % key('DATABASE'))
flask_mongoalchemy.ImproperlyConfiguredError: You should provide a database name (the MONGOALCHEMY_DATABASE setting).
The database name is the final value after the port number in the URI.
When I actually put the database name in like so:
MONGOALCHEMY_CONNECTION_STRING = os.environ["MONGOLAB_URI"]
MONGOALCHEMY_DATABASE="heroku_tchBR549"
I can successfully connect.
init_app actually gets the uri at line 119. It seems that the DATABASE variable check might do it's job in _get_mongo_uri just as well, and avoid this problem by declaring DATABASE by snipping it off the end of CONNECTION_STRING. (unless I'm reading it wrong, and brother, I am prone to that . . .)
Metadata
Metadata
Assignees
Labels
No labels