from pymongo import MongoClient
import sys
client = MongoClient('localhost', 27017)
db = client.test
score = db.week4
def find():
print "command find with selector"
query = {'type': 'exam', 'scores': {'$gt': 50, '$lt': 70}}
try:
cursor = score.find(query)
except:
print "Unexpected error", sys.exc_info()[0]
limit = 0
for doc in cursor:
print doc
limit += 1
if (limit > 10):
break