>>> 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'
>>>
I want to use allow_disk_use()
method but getting the above-mentioned error. My MongoDB server is 4.4.1 and pymongo is also at the latest version.
I have referred to Documentation and Source but I am not able to get what am I doing wrong. Is not supposed to work with Cursor
objects? it would be good if anyone could explain the correct approach and why this isn't working.
In pymongo, you can use
allowDiskUse
in combination withaggregate
:Since version 3.11 you can also pass it to
find()
: