Range Queries

#!/usr/bin/env python
import pprint

client = MongoClient("mongodb://localhost:27017")

db = client.examples

def find():
	query = {"population" : {"$gt" : 250000}}
	cities = db.cities.find(query)

	num_cities = 0
	for c in cities:
		pprint.pprint(c)
		num_cities += 1

	print "\nNumber of cities matching: %d\n" % num_cities
from datetime import datetime

def range_query():
	query = {}
	return query

def get_db():
	from pymongo import MongoClient
	client = MongoClient('localhost:27017')
	db = client.examples
	return db

if __name__ == "__main__":
	db = get_db()
	query = range_query()
	cities = db.cities.find(query)

	print "Found cities:", cities.count()
	import pprint
	pprint.pprint(cities[0])