Logical operators in mongodb queries with python
mongodb, pymongo, python, python-2.7
Solution
Just put it into quotes:
output = collection.find_one({
'$and': [
{'name': data['name']},
{'phone_1': data['phone_1']}
]
})
Problem
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?