Python 如何解决属性错误:';光标';对象没有属性';noCursorTimeout';在pymongo?
我正试图按照MongoDB文档中的指示在会话中设置noCursorTimeout。 但我得到了一个错误:Python 如何解决属性错误:';光标';对象没有属性';noCursorTimeout';在pymongo?,python,python-3.x,pymongo,pymongo-3.x,Python,Python 3.x,Pymongo,Pymongo 3.x,我正试图按照MongoDB文档中的指示在会话中设置noCursorTimeout。 但我得到了一个错误:AttributeError:“Cursor”对象没有属性“noCursorTimeout” 我不知道为什么我会得到这个 from pymongo import MongoClient as Connection from datetime import datetime conn = Connection(get_uri()) with conn as conn: collection
AttributeError:“Cursor”对象没有属性“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},无光标\u timeout=True)
参考: