from pymongo import MongoClient import pprint client = MongoClient("mongodb://localhost:27017") db = client.examples def find(): autos = db.autos.find( { "manufacturer" : "Toyota" , "class": "mid-size car" }) for a in autos: pprint.pprint(a) if __name__ == '__main__': find()
#!/usr/bin/env python from autos import process_file def insert_autos(infile, db): data = process_file(infile) if __name__ == "__main__": from pymongo import MongoClient client = MongoClient("mongodb://localhost:27017") db = client.examples insert_autos('autos-small.csv', db) print db.autos.find_one()