I am trying to query my mongo db for a item in python2.7 with
output = collection.find_one({ $and : [{'name' : data['name']},{'phone_1' : data['phone_1']}]})
when I try to run the script python tell me
File "./test.py", line 113
output = collection.find_one({ $and : [{'name' : data['name']},{'phone_1' : data['phone_1']}]})
                               ^
SyntaxError: invalid syntax
I checked the manual and the version of mongo. I have installed mongodb 2.0.6, so the syntax above should be fine. Am I missing something?
Just put it into quotes:
output = collection.find_one({
    '$and': [
        {'name': data['name']},
        {'phone_1': data['phone_1']}
    ]
})
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With