python - pymongo:如何用字典列表替换许多文档
问题描述
我是 pymongo 的新手,我不明白如何运行从 mysql 到 pymongo 的等价物
"REPLACE INTO XXXX (column1, column2, column3, column4, column5) VALUES" + results
我只是想向 collection.replace_many() 发送一个列表,但它不起作用。我跑
collection.replace_many(<list of dict>)
我收到了这个错误:
TypeError: 'Collection' object is not callable. If you meant to call the 'replace_many' method on a 'Collection' object it is failing because no such method exists.
我正在使用:pymongo.version:'3.11.2'
解决方案
MongoDB doesn't have a ReplaceMany
; the equivalent to REPLACE INTO
is UpdateMany
(update_many()
in pymongo) with Upsert set to True
推荐阅读
- python - (Pandas) 正确的 lambda 表达式按值@索引位置 1 对列进行排序
- pine-script - 浮点数小于 1 的问题
- flutter - 如何在颤动中更改空字值?
- firebase - Flutter 和 Firebase 函数:TypeError:无法读取未定义的属性“令牌”
- python - 如何发出命令找出python3的路径?
- r - rmarkdown yaml 中的顺序或反应参数
- firebase - Flutter Firebase - 允许 null `request.auth.uid` 读取集合文档
- python - 在python中用逗号拆分列表,除非在python中被引号包围
- java - 证书策略 - 多个策略限定符信息
- ruby-on-rails - 如何在 RSpec/Capybara 测试中进行配置更改?