Pymongo报错解决

    pymongo的client方法 连接mongo数据库后,执行命令后报错,OP_QUERY 不支持,客户端驱动需要升级,这就是说明执行mongodb命令的 pymongo版本太低,需要升级。

      1、

 File "/usr/local/python3/lib/python3.8/site-packages/pymongo/helpers.py", line 210, in _check_command_response
    raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: Unsupported OP_QUERY command: listDatabases. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal  

2、

"pymongo.errors.OperationFailure: Unsupported OP_QUERY command: find. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal

      比如Pymongo3.5.1 ,仅仅支持到 MongoDB 2.4, 2.6, 3.0, 3.2, and 3.4;升级到最新版本4.3.3之后,既可以支持到 MongoDB 3.6, 4.0, 4.2, 4.4, 5.0, and 6.0. 经测试发现对于Pymongo 4.3.3 对于较低版本的MongoDB也是能兼容执行相关的命令。

posted on 2022-12-09 23:28  兵者  阅读(1567)  评论(1编辑  收藏  举报

导航