【发布时间】:2021-02-02 02:38:09
【问题描述】:
>>> from pymongo import MongoClient
>>> client = MongoClient()
>>> db = client['cvedb']
>>> db.list_collection_names()
['cpeother', 'mgmt_blacklist', 'via4', 'capec', 'cves', 'mgmt_whitelist', 'ranking', 'cwe', 'info', 'cpe']
>>> colCVE = db["cves"]
>>> cve = colCVE.find().sort("Modified", -1) # this works
>>> cve_ = colCVE.find().allow_disk_use(True).sort("Modified", -1) # this doesn't work
AttributeError: 'Cursor' object has no attribute 'allow_disk_use'
>>> cve_ = colCVE.find().sort("Modified", -1).allow_disk_use(True) # this doesn't work
AttributeError: 'Cursor' object has no attribute 'allow_disk_use'
>>> cve.allow_disk_use(True) # this doesn't work
AttributeError: 'Cursor' object has no attribute 'allow_disk_use'
>>>
我想使用allow_disk_use() 方法但得到上述错误。我的 MongoDB 服务器是 4.4.1,pymongo 也是最新版本。
我提到了Documentation 和Source,但我不知道我做错了什么。不应该与Cursor 对象一起使用吗?如果有人能解释正确的方法以及为什么这不起作用,那就太好了。
【问题讨论】:
标签: python python-3.x mongodb pymongo pymongo-3.x