Skip to main content

移除 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, 运行时跟着提示填写即可

数据贵无价 操作需谨慎

Metadata

Release files for mongochecker 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mongochecker 0.0.2
File Size Uploaded
mongochecker-0.0.2.tar.gz 6.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mongochecker 0.0.2
File Interpreter ABI Platform
mongochecker-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / mongochecker-0.0.2.tar.gz

Download URL mongochecker-0.0.2.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c7c8bd569950712b401cd28e36b0b5ff1def43d1d13ca0bba38a69d0e59c0559
BLAKE2b-256 checksum
How to use checksums
d0d3e93bd615a1a2799c714912135f065392b96073b55fa0c5424be30d225cb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

Release files / mongochecker-0.0.2-py3-none-any.whl

Download URL mongochecker-0.0.2-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
052d3fab45e8f5df12029aa2552809b81641c4c085f7556603089521f299f933
BLAKE2b-256 checksum
How to use checksums
afd8c02921436c66cc9019dc060ebb761241d17a9395680ecec2c52f819c9656
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page