I'm trying to write a function to connect to mongodb and return a collection object. I have the following:
def getCollection(dbname,collection): client = MongoClient() data_base = client.dbname collObject = data_base.collection return collObject When I run:
collection = getCollection(client, "hkpr_restore", "agents") print collection I get:
Collection(Database(MongoClient('localhost', 27017), u'dbname'), u'collection') What am I doing wrong?