I was trying to connect to Mongo collection where each time collection and query is different.I'm trying to write a function where user will pass collection name and query string and user will get cursor as a result. But this function is not connecting to collection passed in variable but instead appends variable name to connection object, here 'coll'. it is also appending the query string instead of executing it. I have tried executing query by hard coding collection name.But in that case as well it doesn't executes the query. my code goes like this:
def mongo_result(coll,query_string):
conn_obj=mongo_connection() #mongo_connection()-returns connection object
_collection=conn_obj.coll #collection: name of collection passed #while calling function**#Query string: query passed to function**
result=_collection.query_string #errorneous statement
return result