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

txmongo list of collections not returned #209

Open
ashishRay12 opened this issue Jun 21, 2017 · 8 comments
Open

txmongo list of collections not returned #209

ashishRay12 opened this issue Jun 21, 2017 · 8 comments

Comments

@ashishRay12
Copy link

txmongo dosen't return list of all collections.Inserts and deletes works just fine.Below is the code that is being used.


from txmongo.connection import ConnectionPool
from twisted.internet import defer, reactor
import time


@defer.inlineCallbacks
def mongoHost():
    mongodb_uri = "mongodb://%s:%s" % ('127.0.0.1', '27017')
    mongo = yield ConnectionPool(mongodb_uri)
    defer.returnValue(mongo)


@defer.inlineCallbacks
def query_to_db():
    mongo = yield mongoHost()
    db = mongo['clients']
    coll = yield db.collection_names() # <------------------dosen't works!
    # coll = yield db.facebook.find({})  <------------------works !
    print coll

if __name__ == '__main__':
    reactor.callLater(1, query_to_db)
    reactor.run()

@IlyaSkriblovsky
Copy link
Contributor

Oops, you are right, it seems to be broken on MongoDB 3.x

@IlyaSkriblovsky
Copy link
Contributor

As a workaround you can probably try yield db.command("listCollections")

@ashishRay12
Copy link
Author

@IlyaSkriblovsky thanks :)

@psi29a
Copy link
Contributor

psi29a commented Jun 21, 2017

Nice find, time for another component test. :)

@anekix
Copy link

anekix commented Jun 21, 2017

@IlyaSkriblovsky @psi29a it works in MongoDB 3.0.12. verified

@anekix
Copy link

anekix commented Jun 21, 2017

@ashishRay12 what version are you using?

@ashishRay12
Copy link
Author

ashishRay12 commented Jun 21, 2017

@anekix i am using MongoDB 3.2.14.

@IlyaSkriblovsky
Copy link
Contributor

collection_names() is using system.namespaces special collection that was deprecated in 3.0 and probably removed in 3.2: https://docs.mongodb.com/manual/reference/system-collections/#.system.namespaces

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

No branches or pull requests

4 participants