Dynamic query in mongodb and variable
Chris Angelico
rosuav at gmail.com
Mon Jul 11 09:01:18 EDT 2016
On Mon, Jul 11, 2016 at 10:52 PM, MG <m.gamberi at gmail.com> wrote:
> 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.
What do you want it to be, if not a string? Do you want to pass a
dictionary? Then do - just pass it in directly.
(Side point: I think you mean "lookup_info", not "lockup_info".)
ChrisA
More information about the Python-list
mailing list