日期:2014-05-16  浏览次数:20440 次

python 连接mongo数据库,进行简单的增删该查
实例:
# -*- coding: cp936 -*-
import pymongo

dictSearContion = {'STATE_1':1, 'STATUS':1}

client = pymongo.MongoClient("192.168.0.103", 27017)
replyDB = client.REPLY
topicDB = client.TOPIC

def getExcelTopics(collectionName):
    topics = topicDB.TOPIC_COL.find(dictSearContion)
    for i in topics:
        print i



if __name__=='__main__':
    getExcelTopics("TOPIC_COLL")