我将尝试将名为
我使用的代码是:
但是后来我遇到了一个错误,显示为
我找到了一个链接,描述了类似的情况,但并没有解释这种情况发生的原因或如何解决此问题。该链接在以下位置的_Why does PyMongo add an id field to all of my documents?下:
https://github.com/mongodb/mongo-python-driver/blob/master/doc/faq.rst#id25
posts
的以下字典列表插入到Mongo中,但出现了一个BulkWriteError: batch op errors occurred
错误,我不知道如何解决。
posts:
[{'#AUTHID': 'fffafe151f07a30a0ede2038a897b680',
'Records': [
{'DATE': '07/22/09 05:54 PM',
'STATUS': 'Is flying back friday night in time to move the rest of his stuff then go to work the next morning... great.'},
......
{'DATE': '07/19/09 04:39 PM', 'STATUS': 'is stealing his net by the lake'}]},
{'#AUTHID': 'fffafe151f07a30a0ede2038a897b680',
'Records': [
{'DATE': '07/22/09 05:54 PM',
'STATUS': 'Is flying back friday night in time to move the rest of his stuff then go to work the next morning... great.'},
{'DATE': '07/19/09 04:39 PM', 'STATUS': 'is stealing his net by the lake'},
....
我使用的代码是:
collection = db.posts
collection.insert_many(p for p in posts )
但是后来我遇到了一个错误,显示为
BulkWriteError:批处理操作错误
,只成功导入了第一个字典(对应于第一个#AUTHID
)。我找到了一个链接,描述了类似的情况,但并没有解释这种情况发生的原因或如何解决此问题。该链接在以下位置的_Why does PyMongo add an id field to all of my documents?下:
https://github.com/mongodb/mongo-python-driver/blob/master/doc/faq.rst#id25