Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection URI string still requires setting of a DATABASE variable. #45

Open
lysdexia opened this issue Dec 18, 2015 · 1 comment
Open

Comments

@lysdexia
Copy link

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 . . .)

@pattoM
Copy link

pattoM commented Aug 1, 2018

Similar issue 3 years later. Anyone know a fix ? Problem with my set up maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants