A package to check mysql restore integrity check
Project description
MySQL restore integrity check
Module can be used to test the database integrigity after restore the database. It will compare tables and show the only that tables in tabular format, Which had diffrencial records in after restore.
Requirements
- python3.6 or above
- tablular and os python plugin should be installed using pip3
How to use
$ pip3 install databaseRestoreIntegrity
$ export SRC_DB_HOST='origin_database_hostname'
$ export SRC_DB_USER='origin_database_username'
$ export SRC_DB_PASS='origin_database_password'
$ export DST_DB_HOST='restored_database_hostname'
$ export DST_DB_USER='restored_database_username'
$ export DST_DB_PASS='restored_database_password'
Now create and run a python scrip using the content below
from databaseRestoreIntegrity import mysql
from tabulate import tabulate
import os
src_db_host = os.environ['SRC_DB_HOST']
src_db_pass = os.environ['SRC_DB_PASS']
src_db_user = os.environ['SRC_DB_USER']
dst_db_host = os.environ['DST_DB_HOST']
dst_db_pass = os.environ['DST_DB_PASS']
dst_db_user = os.environ['DST_DB_USER']
database = mysql.mysqlRestroeCheck(src_db_host, src_db_user, src_db_pass)
database1 = mysql.mysqlRestroeCheck(dst_db_host, dst_db_user, dst_db_pass)
database._create_tmp_table('restore_rds')
database1._create_tmp_table('actual_rds')
def check_consistency():
unconsistent_tabels = []
conn = database.connection()
check_consistency = conn.cursor()
check_consistency.execute("USE restore_consistency")
check_consistency.execute("SELECT tables_name,records_count,hostname FROM (SELECT tables_name,records_count,hostname FROM restore_rds UNION ALL SELECT tables_name,records_count,hostname FROM actual_rds) tbl GROUP BY tables_name, hostname, records_count HAVING count(*) = 1 ORDER BY tables_name")
result = check_consistency.fetchall()
print(tabulate(result, headers=['tables_name', 'records_count'], tablefmt='psql'))
check_consistency()
Copyright (c) 2018 The Python Packaging Authority
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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
Built Distribution
Hashes for databaseRestoreIntegrity-1.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8799d68c05fa9d6ac29e91c20142d333dbbf35e40549c808e8bf790b08e83139 |
|
MD5 | dfabdc25d6b3807312ab001a1abe3016 |
|
BLAKE2b-256 | 50ac186bfbc93624638590bb9a15daa69a30d71aef7a60aa498b2da2d90cda4e |
Hashes for databaseRestoreIntegrity-1.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90c640042ba560c734f6d54e7ca4ff418badd5b04161b26b52a43b5f9c4533f1 |
|
MD5 | 8a098919958d2195d46e03ad972222bb |
|
BLAKE2b-256 | b32df3729c1ce13bcef84dbfb1962fa1c4e23d67138351457b5f87aa659eb50b |