【发布时间】:2016-11-10 10:39:14
【问题描述】:
我目前正在使用 Python3 (pymongo) 连接到支持 Mongo 协议的 Azure 文档数据库。
# reference to connection string
self.connection_string = "mongodb://<user>:<pw>@<location>:<port>/<database>?ssl=true"
# creates the connection (this is working)
self.mongo_client = MongoClient( self.connection_string )
# show databases and there collections
print(self.mongo_client.database_names())
for db_name in self.mongo_client.database_names():
print(db_name,">",self.mongo_client[db_name].collection_names())
运行上面的 sn-p 代码会列出数据库,但不会列出集合。在本地 mongo db 上运行它可以按预期工作。
我最初试图在数据库中的已知集合上运行查询,但是,我什至似乎无法做到这一点。我已连接 MongoChef,并且正在按预期工作(能够运行查询)。
有什么想法我可能做错了吗?
【问题讨论】:
-
据我所知,当前版本的文档 db 上的 mongo 协议似乎不支持这一点,这就是它返回空列表的原因。
标签: python mongodb azure azure-cosmosdb