我试图在我的python脚本中使用mongoengine插入文档,但它引发了这个异常
(<class 'pymongo.errors.InvalidName'>, InvalidName("database names cannot contain the character '.'",), <traceback object at 0x000000000844F708>)
连接字符串是mongodb:// user:[email protected]:42487 / db-name
对于如何解决这个问题,有任何的建议吗??
谢谢
你的数据库名称不应该是contain any of these characters: ' ', '.', '$', '/', '\\', '\x00', '"'
检查数据库名称。 Mongo驱动程序还强制执行此规则,因此您的名称中包含点的数据库的可能性很小。
而不是使用
connect("mongodb://user:[email protected]:42461/db-name")
用这个
connect( db='db-name', username='user', password='pass', host='mongodb://user:[email protected]:42461/db-name')
它对我有用。 :)