This tool is useful for finding full table differences between a source and a target. In order to utilize the tool:
- clone this repo
- update
.env.templateto.envand add the proper source and target URIs in the format provided (specifically the databases and schemas). Make sure to either use thePasswordformat orSSOformat and delete the other one which is not used.
Note
You will have to urlencode your email address, replacing [email protected] with name%40domain.com. If using password auth, you will have to do the same with your password. There are many tools online to do this such as urlencoder.org
- install required libraries with
python -m pip install -r requirements.txt- a virtual environment is recommended prior to installing the project's required packages, and can be created with the following commands
python -m venv venv
source venv/bin/activate #(or source venv/Scripts/activate on Windows)- update
config.ymlto include:- the tables to compare
- the key column shared between the tables
- any where clauses to properly filter the tables
- the additional columns to compare
Note
Excluding additional columns in the config will currently only check if the key column is found in both tables, but not if there are different values in any columns between the two tables for each key.
To compare column values you must add additional columns to the config in the columns entry, and their names must match across both tables.
- run the comparison with
python -m diff- this will compare the 2 tables and output the results to
diff_report.txt
- this will compare the 2 tables and output the results to
Important
Make sure to take a copy of the initial report, as it may be overwritten as you develop.
{KEY_COLUMN} {COLUMN_VALUE} changes in {TABLE}: {COLUMN1}: -{LEFT_VALUE} +{RIGHT_VALUE}, {COLUMN2}: -{LEFT_VALUE} +{RIGHT_VALUE}For example, in the below where MY_TABLE is the table being compared:
ID 12345 changes in MY_TABLE: COLUMN_1: -670 +'', COLUMN_2: -F1 +''ID 12345 has a value of 670 in the
COLUMN_1column in the source table, and a value of''in the target table, and a value ofF1in theCOLUMN_2column in the source table, and a value of''in the target table.
This project would not be possible without reladiff