"AttributeError: 'GridFS' object has no attribute 'find'"
"AttributeError: 'GridFS' object has no attribute 'find'"
我正在使用 pymongo 版本 2.6.3,我将文件保存在 mongo 中的 gridfs 中,突然 gridfs 出错了。
AttributeError: 'GridFS' 对象没有属性 'find'
我的代码是:
import gridfs
admin_db = MDB_CONN['admin']
admin_db.authenticate(mongo_admin, mongo_password)
db = MDB_CONN["dbname"]
grid = gridfs.GridFS(db,collection="collectionName")
grid_cursor = grid.find({'file_hash':self.object_id},timeout=False, limit=1)
在此先感谢您的帮助。
您收到此错误是因为 no find()
method in version 2.6.3 of the driver; it was added in version 2.7:
PyMongo 2.7 is a major release with a large number of new features and
bug fixes. Highlights include:
- Full support for MongoDB 2.6.
- A new bulk write operations API.
- Support
for server side query timeouts using max_time_ms().
- Support for
writing aggregate() output to a collection.
- A new parallel_scan()
helper.
- OperationFailure and its subclasses now include a details
attribute with complete error details from the server.
- A new GridFS
find() method that returns a GridOutCursor.
- Greatly improved support
for mod_wsgi when using PyMongo’s C extensions. Read Jesse’s blog post
for details.
- Improved C extension support for ARM little endian.
您应该将您的驱动程序升级到支持的最新版本。
我正在使用 pymongo 版本 2.6.3,我将文件保存在 mongo 中的 gridfs 中,突然 gridfs 出错了。 AttributeError: 'GridFS' 对象没有属性 'find' 我的代码是:
import gridfs
admin_db = MDB_CONN['admin']
admin_db.authenticate(mongo_admin, mongo_password)
db = MDB_CONN["dbname"]
grid = gridfs.GridFS(db,collection="collectionName")
grid_cursor = grid.find({'file_hash':self.object_id},timeout=False, limit=1)
在此先感谢您的帮助。
您收到此错误是因为 no find()
method in version 2.6.3 of the driver; it was added in version 2.7:
PyMongo 2.7 is a major release with a large number of new features and bug fixes. Highlights include:
- Full support for MongoDB 2.6.
- A new bulk write operations API.
- Support for server side query timeouts using max_time_ms().
- Support for writing aggregate() output to a collection.
- A new parallel_scan() helper.
- OperationFailure and its subclasses now include a details attribute with complete error details from the server.
- A new GridFS find() method that returns a GridOutCursor.
- Greatly improved support for mod_wsgi when using PyMongo’s C extensions. Read Jesse’s blog post for details.
- Improved C extension support for ARM little endian.
您应该将您的驱动程序升级到支持的最新版本。