![](/img/trans.png)
[英]Why pymongo throwing Attribute-error: 'Cursor' object has no attribute 'find' on second time execution
[英]How to solve attribute error: 'Cursor' object has no attribute 'noCursorTimeout' in pymongo?
我正在嘗試按照 MongoDB 文檔的說明在 session 中設置 noCursorTimeout 。 但我收到錯誤: AttributeError: 'Cursor' object has no attribute 'noCursorTimeout'
我不知道為什么我會得到這個。
from pymongo import MongoClient as Connection
from datetime import datetime
conn = Connection(get_uri())
with conn as conn:
collection = conn['db_name']['my_collection']
documents_cursor = collection.find(query).noCursorTimeout() # same with .maxTimeMS()
根據文檔,您應該像這樣使用它:
cursor = collection.find({"a": 1}, no_cursor_timeout=True)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.