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

MONGO_URI forcefully expects database name #117

Closed
bhairav13 opened this issue Nov 1, 2018 · 5 comments

Comments

@bhairav13
Copy link

commented Nov 1, 2018

Hello,

I configure MONGO_URI as shown below:

    app.config.update(
        # Documentation says URI is preferred
        MONGO_URI="mongodb://{}:{}/".format(dbhost, int(dbport) or 27017),
        # Use OrderedDict for the documents
        MONGO_DOCUMENT_CLASS=OrderedDict,
    )
    connection = PyMongo(app)

I don't include the database name because I prefer to make a connection and get a list of the databases first. Then I "attach" to the databases one-by-one to extract some information from them.

However, I now get a ValueError exception that: "Your URI must specify a database name".

Is there any way to not force having to supply the database name? This used to work in versions < 2, so hoping we can get a similar behavior in the newer versions.

@dcrosta

This comment has been minimized.

Copy link
Owner

commented Nov 1, 2018

That seems reasonable. I've cut a new branch (https://github.com/dcrosta/flask-pymongo/tree/allow-no-db-name), and if everything looks good on the build, I'll try to cut the release later today.

@bhairav13

This comment has been minimized.

Copy link
Author

commented Nov 1, 2018

Wow! Many thanks for the quick turn-around!

@dcrosta dcrosta closed this in 3738580 Nov 1, 2018

@dcrosta

This comment has been minimized.

Copy link
Owner

commented Nov 1, 2018

https://pypi.org/project/Flask-PyMongo/2.2.0/ just published :) happy hacking

@bhairav13

This comment has been minimized.

Copy link
Author

commented Nov 2, 2018

Thank you @dcrosta. I'll pick it up and test it out immediately. Just an FYI, on the below page, the 2.2.0 version is referring to Issue #114 instead of this issue (#117).

@dcrosta

This comment has been minimized.

Copy link
Owner

commented Nov 2, 2018

🤦‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.