zoukankan      html  css  js  c++  java
  • mongo客户端升级导致pymongo中使用聚合函数时出现异常

    一.异常信息

    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)
     
    
  • 相关阅读:
    fake data
    template 的简单使用
    computed what time passage pushed-
    drag And drop
    threeJs(1)
    使用babel
    PHP海补知识(2)-- 复合赋值操作
    PHP海补知识(1)-- 可变变量
    一个裸的Ubuntu系统,搭建LAMP需要配置这些东西
    Ubuntu Server 12.04 U盘启动盘打包
  • 原文地址:https://www.cnblogs.com/pythonywy/p/12187986.html
Copyright © 2011-2022 走看看