How to fetch Mongo documents based on query expression /condition via python?

use pymongo library to connect to Mongodb from python

Q)How to install pymongo library via setup tools?
A)easy_install pymongo

script:
import pymongo
from pymongo import MongoClient

mghost = 'localhost'
mgport = 27017
mgdbname = 'zolo_production'
mgclient = MongoClient(mghost, mgport)
db = mgclient[mgdbname]
centers = db.centers;

center = centers.find_one({'zoloCode' : pgcode})

No comments:

Post a Comment