mongo客户端升级导致pymongo中使用聚合函数时出现异常
程序员文章站
2022-05-29 07:53:40
一.异常信息 二.解决办法 ......
一.异常信息
the 'cursor' option is required, except for aggregate with the explain argument
二.解决办法
#部分源代码错误代码 pipeline = [ {"$match": { "updatetime": { "$gte":(datetime.datetime(year,month,day, 0, 0, 0, 000) - datetime.timedelta(hours=8)), "$lte":(datetime.datetime(year,month,day, 23, 59, 59, 000) - datetime.timedelta(hours=8))}, "type": self.type}}, {"$group": {"_id": {"platformname": "$platformname"}, "count": {"$sum": 1}}}, {"$match": {"count": {"$gt": 1}}}] every_zb_num = self.db_data.command('aggregate', self.tablename, pipeline=pipeline,allowdiskuse=true) #解决办法添加游标 pipeline = [ {"$match": { "updatetime": { "$gte":(datetime.datetime(year,month,day, 0, 0, 0, 000) - datetime.timedelta(hours=8)), "$lte":(datetime.datetime(year,month,day, 23, 59, 59, 000) - datetime.timedelta(hours=8))}, "type": self.type}}, {"$group": {"_id": {"platformname": "$platformname"}, "count": {"$sum": 1}}}, {"$match": {"count": {"$gt": 1}}}] #在执行的时候添加游标参数 every_zb_num = self.db_data.command('aggregate', self.tablename,cursor = {}, pipeline=pipeline,allowdiskuse=true)
上一篇: 三、Nginx原理解析
下一篇: uncurl 接口数据变python代码