zl程序教程

您现在的位置是:首页 >  其它

当前栏目

pymongo的几个操作

操作 几个 pymongo
2023-09-14 09:06:37 时间
# -*- coding: utf-8 -*-
# @Time    : 2018/9/11 17:16
# @Author  : cxa
# @File    : mongotest.py
# @Software: PyCharm
import pymongo

client = pymongo.MongoClient(host='172.17.0.170')
db = client.库名
collection = db.表名
print(collection.find({'status':0}).count())#查找status字段值为0的 数据的条数
#collection.update_many({},{'$set':{'status':0,'last_crawl_time':0}}) #更新所有的状态
#c2.update_many({'status':3},{'$rename': {'type_url ': 'type_url'}})  #修改表名
# results = collection.find({'status': 1})