1. connection
option 1
import pymongo from pymongo import MongoClient con=MongoClient('localhost',27017) db=con.db# database name "db" names=db.users # collection name "users"
item=names.find_one() print item['name']
option2: deprecated
import pymongo import sys con= pymongo.Connection("mongodb://localhost",safe=True) db=con.reddit doc=db.stories