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 · 6 comments
Closed

MONGO_URI forcefully expects database name #117

bhairav13 opened this issue Nov 1, 2018 · 6 comments

Comments

@bhairav13
Copy link

@bhairav13 bhairav13 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
Copy link
Owner

@dcrosta dcrosta 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
Copy link
Author

@bhairav13 bhairav13 commented Nov 1, 2018

Wow! Many thanks for the quick turn-around!

@dcrosta dcrosta closed this in 3738580 Nov 1, 2018
@dcrosta
Copy link
Owner

@dcrosta dcrosta commented Nov 1, 2018

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

@bhairav13
Copy link
Author

@bhairav13 bhairav13 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
Copy link
Owner

@dcrosta dcrosta commented Nov 2, 2018

🤦‍♂️

@renmu123
Copy link

@renmu123 renmu123 commented Oct 13, 2019

How can l use this feature.1 can't find example fo this.

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

Successfully merging a pull request may close this issue.

None yet
3 participants