时间:2021-07-01 10:21:17 帮助过:46人阅读
创建连接Connection
>>> conn = pymongo.Connection('localhost',27017)
>>> conn = Connection('localhost',27017)
连接数据库
>>> db.Account.find_one({"UserName":"keyword"})
查看聚集的字段
>>> db.Account.find_one({},{"UserName":1,"Email":1,"_id":0})
{u'UserName': u'libing', u'Email': u'libing@35.cn'}
查看聚集的多条记录
>>> for item in db.Account.find({"UserName":"libing"}):
item["UserName"]
>>> db.Account.find({"UserName":"keyword"}).count()
聚集查询结果排序
聚集查询结果多列排序
添加记录
修改记录
删除记录
>>> db.Test.remove({"UserName":"keyword"})