【问题标题】:how to export the existing documents stored in a database from MongoDb Atlas free cloud version?如何从 MongoDb Atlas 免费云版导出存储在数据库中的现有文档?
【发布时间】:2020-06-16 16:54:59
【问题描述】:

我已将大约 50 万个文档存储在一个数据库中的一个集合中,该集合是通过名为 MongoDB Atlas 的免费云版本 MongoDB 提供的免费集群上的。我总共有 512 MB 可用存储空间,所以我需要删除这些数据,但首先我需要将数据导出到 csv 文件或 excel 中。

我刚刚安装了 MongoDB shell 并正在使用 Pymongo 驱动程序连接到数据库。我没有在我的机器上本地安装 MongoDB。

我尝试从命令行使用 Mongoexport,但它没有工作,表明该命令无法识别。我正在使用 python。

【问题讨论】:

标签: python mongodb csv export pymongo


【解决方案1】:

假设您的系统中已经安装了Command-Line Tool

mongoexport -h <hostname:port> -d <db name> -c <collection> -u <user> -p <password> -o <output file>

应该导出您收藏的 JSON。 如果您想要一个二进制导出以便将来在不同的基础架构中恢复,您应该使用

mongodump -h <hostname:port> -d <db name> -c <collection> -u <user> -p <password> -o <output file>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多