Skip to main content

a tool to remove mongodb duplicate data or copy mongodb data

Project description

移除 mongodb 的重复数据的小工具

  • 可以去除重复数据 >>> mongochecker

  • 可以复制数据 >>> mongocopy

安装:

$ pip install mongochecker

1. 去重功能介绍:

运行:

$ mongochecker [mongodb setting file path]

mongodb setting file 格式:

[
    {"host": "127.0.0.1",
      "port": 27017,
      "name": "root",
      "password": "123456",
      "source": "admin",
      "db": "mydb1"
    },
    {"host": "111.123.234.321",
      "port": 27017,
      "name": "root",
      "password": "123456",
      "source": "admin",
      "db": "mydb1",
      "collection": "my_collection",
      "check_keys": ["key1", "key2"]
    }
]

说明:

 1. mongodb setting file 必须是 json 格式
 2. 一个 mongodb setting file 可以是一个 mongodb 设置的字典, 也可以是多个mongodb 设置组成的列表
 3. 配置里 host 和 port 是必须的, 如果开启了认证, 则 name, password, source 也是必须有的
 4. 除了上述的必须配置, db 是用来指定操作的数据库的, collection 是用来指定操作的集合的, check_keys 是用来指定集合过滤字段的
 5. 也可以不指定 mongodb setting file, 运行时跟着提示填写即可

数据贵无价 操作需谨慎

2. 复制功能介绍:

运行:

$ mongocopy [mongodb copy setting file path]

mongodb copy setting file 格式:

{
  "from": {
    "host": "127.0.0.1",
    "port": 27017,
    "user": "root",
    "password": "123456",
    "source": "admin",
    "db": "source_db",
    "from_collection": "source_collection",
    "condition": {
      "class": "1"
    }
  },
  "to": {
    "host": "127.0.0.1",
    "port": 27017,
    "user": "root",
    "password": "123456",
    "source": "admin",
    "db": "target_db",
    "to_collection": "target_collection",
    "filter": {
      "name": ""
    }
  }
}

说明:

 1. mongodb setting file 必须是 json 格式
 2. 一个 mongodb setting file 可以是一个 mongodb 设置的字典, 也可以是多个mongodb 设置组成的列表
 3. 配置里 host 和 port 是必须的, 如果开启了认证, 则 name, password, source 也是必须有的
 4. 除了上述的必须配置, db 是用来指定操作的数据库的, collection 是用来指定操作的集合的, check_keys 是用来指定集合过滤字段的
 5. 也可以不指定 mongodb setting file, 运行时跟着提示填写即可

数据贵无价 操作需谨慎

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mongochecker, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size mongochecker-0.0.2-py3-none-any.whl (8.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size mongochecker-0.0.2.tar.gz (6.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page