MongoEngine: database names cannot contain the character '.'

I am trying to insert document using mongoengine in my python script but it raises this exception

(<class 'pymongo.errors.InvalidName'>, InvalidName("database names cannot contain the character '.'",), <traceback object at 0x000000000844F708>) 

Connection string is mongodb://user::42487/db-name

Any suggestions on how to fix this??

Thanks

3

3 Answers

Rather than using

connect("mongodb://user::42461/db-name")

use this

connect( db='db-name', username='user', password='pass', host='mongodb://user::42461/db-name')

It worked for me. :)

Your database name shouldn't contain any of these characters: ' ', '.', '$', '/', '\\', '\x00', '"'

Check your database name. The Mongo driver also enforces this rule so the chance that you have a database with a dot in its name is slim.

1

I use python driver 3.4v which is shared cluster format connection string, I try diferent connection string but it doesn't work for me, here's the Connection Strings URI Format for mongoengine

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like