对比工具集
Project description
对比工具集
一. 项目介绍
做一个快速的对比工具集
目前实现功能
- 数据库对比
- mysql
- pgsql
二. 数据库对比
1. 安装
pip install diff-kit
2. 使用
from diff_kit.db_diff.core import DbDiffRunner
"""
参数说明:
report_name: str 报告名称
db_type: str 数据库类型,目前支持[mysql, pgsql]
db_conn_a: dict 数据库连接信息 {"host": "127.0.0.1", "port": 3306, "user": "root", "password": "123456"}
db_conn_b: dict 数据库连接信息 {"host": "127.0.0.1", "port": 3306, "user": "root", "password": "123456"}
db_name_a: str,数据库A的名称。
table_name_a: str,表A的名称。
table_name_b: str,表B的名称。
db_name_b: str = None,数据库B的名称,默认为None。
query_condition_a: str = None,查询条件A,为字符串格式,默认为None。
query_condition_b: dict = None,查询条件B,为字典格式,默认为None。
diff_columns: list = None,需要进行差异比较的列名列表,默认为None。
exclude_columns: list = None,需要排除在比较之外的列名列表,默认为None。
mapping: dict = None,列名映射字典,用于指定表A的列名如何映射到表B的列名,默认为None。
compare_count: bool 是否只对比行数
only_generate_failed_report: 是否仅失败时生成报告,
report_type: str = 'excel', 报告类型,默认excel 可选['excel', 'text]
"""
params = {
"report_name": "demo",
"db_type": "mysql",
"db_conn_a": {"host": "127.0.0.1", "port": 3306, "user": "root", "password": "123456"},
"db_conn_b": {"host": "127.0.0.1", "port": 3306, "user": "root", "password": "123456"},
"db_name_a": "test",
"table_name_a": "test_table1",
"table_name_b": "test_table2",
"query_condition_b": ["id"],
}
DbDiffRunner(**params).diff()
3. 查看报告
报告在output目录下
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
diff_kit-0.1.5.tar.gz
(18.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
diff_kit-0.1.5-py3-none-any.whl
(23.1 kB
view details)
File details
Details for the file diff_kit-0.1.5.tar.gz.
File metadata
- Download URL: diff_kit-0.1.5.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
417a02bb0fbc5fda8569f6b7f1e68be6039e3562ee392b89fa7cf08adb991ab0
|
|
| MD5 |
eea372f290b23699f9edf35d42936ca2
|
|
| BLAKE2b-256 |
89f29da3c781a0d61b4b6bb7bd1ab0f16610fb7f3760320ca0e59278a1b1927f
|
File details
Details for the file diff_kit-0.1.5-py3-none-any.whl.
File metadata
- Download URL: diff_kit-0.1.5-py3-none-any.whl
- Upload date:
- Size: 23.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32ece5bfa5eeef75bb8fc1f7314929dfa4bf09771b66fd30a43b4c3e3bd25c3a
|
|
| MD5 |
545f4346a5e148141f3f1c6bf38bce13
|
|
| BLAKE2b-256 |
3a3d4a67d820207fdce32c0516ee8ee90f250bc999762d358da064d2b4bed4a2
|