我正在按照教程进行操作http://api.mongodb.org/python/current/tutorial.html http://api.mongodb.org/python/current/tutorial.html用于批量插入。但是,我收到下面列出的错误。我缺少什么? Reviews_array 是一个 json_array
client = MongoClient()
client = MongoClient('localhost', 27017)
db = client.is_proj
db_handle = db.reviews
self.db_handle.insert_many(reviews_array)
错误:
TypeError: 'Collection' object is not callable. If you meant to call the 'insert_many' method on a 'Collection' object it is failing because no such method exists.
在皮蒙戈中,V3.0之前, 你用insert http://api.mongodb.org/python/current/api/pymongo/collection.html#pymongo.collection.Collection.insert对于单个文档和批量插入。如果您传递一个文档,它会执行单个插入,如果您传递一个不同的可迭代对象(列表、生成器),它会执行批量插入。
insert_many()
V3.0之前的pymongo中不存在。
在pymongo V3.0中,他们介绍了insert_many http://api.mongodb.org/python/current/api/pymongo/collection.html#pymongo.collection.Collection.insert_many and insert_one http://api.mongodb.org/python/current/api/pymongo/collection.html#pymongo.collection.Collection.insert_one,以及使用普通的insert
已弃用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)