Dynamic query in mongodb and variable

MG m.gamberi at gmail.com
Mon Jul 11 08:52:34 EDT 2016


Ciao,
I have this function:


    def lockup_info(refer):
        info = []
        amb = CONN.db.xxxx.find({"reference": refer}
        for a in amb:
            print a



How can I pass this value { "$exists": False } and tell python to not consider it as a string?

    var = '{ "$exists": False }'
    lockup_info(var)



The code above doesn't work. A variable so defined is considered a string.
Thanks



More information about the Python-list mailing list