python - unable to list collections in azure document db with mongodb protocol support -
i using python3 (pymongo) connect azure document db mongo protocol support.
# reference connection string self.connection_string = "mongodb://<user>:<pw>@<location>:<port>/<database>?ssl=true" # creates connection (this working) self.mongo_client = mongoclient( self.connection_string ) # show databases , there collections print(self.mongo_client.database_names()) db_name in self.mongo_client.database_names(): print(db_name,">",self.mongo_client[db_name].collection_names())
running above snippet of code lists databases collections not listed. running on local mongo db works expected.
i trying run query on known collection within database however, can't seem able that. have mongochef connected , working expected (able run querys).
any ideas doing wrong?
@greener, issue seems caused pymongo
, not documentdb mongodb protocol
.
i tried connect documentdb mongodb protocol
using third party tool robomongo
successfully, , see collections below.
as reference, here workaround way listing collections in pymongo via database level command listcollections
, please see below.
>>> mongo_client.command('listcollections') {'ok': 1, '_t': 'listcollectionsresponse', 'cursor': {'firstbatch': [{'options': {}, 'name': 'testcollection'}], 'ns': 'testdb.$cmd.listcollections', 'id': 0}}
hope helps.
Comments
Post a Comment