Skip to main content

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']



restored_db = mysql.mysqlReadData(dst_db_host, dst_db_user, dst_db_pass)
active_db = mysql.mysqlReadData(src_db_host, src_db_user, src_db_pass)

restored_db._create_tmp_file('restored_db')
active_db._create_tmp_file('active_db')
restored_db._insert_data('restored_db')
restored_db._insert_data('active_db')


def check_consistency():
    unconsistent_tabels = []
    conn = restored_db.connection()
    check_consistency = conn.cursor()
    check_consistency.execute("USE CheckDBsTableConsistency")
    check_consistency.execute("select tables_name, records_count, hostname from (select tables_name, hostname, records_count from active_db union all select tables_name, hostname, records_count from restored_db) temp group by tables_name, records_count having count(*) = 1")
    result = check_consistency.fetchall()
    print(tabulate(result, headers=['tables_name', 'records_count'], tablefmt='psql'))
    conn.close()
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


Download files

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

Source Distribution

databaseRestoreIntegrity-1.0.8.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

databaseRestoreIntegrity-1.0.8-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file databaseRestoreIntegrity-1.0.8.tar.gz.

File metadata

File hashes

Hashes for databaseRestoreIntegrity-1.0.8.tar.gz
Algorithm Hash digest
SHA256 8fb5f3380deaeebe974079cd73ec130c1e5cb9dbf689ae1829b78c0456a86ec0
MD5 95774cc103526d5ec55ddc30c379ef60
BLAKE2b-256 385669958b6e0520c2e8a2fcbc7723a772be95c4663b4ec04ba4d3a1ec418111

See more details on using hashes here.

File details

Details for the file databaseRestoreIntegrity-1.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for databaseRestoreIntegrity-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 d4abadcab90278a8f511dce615360211e79848ce4eeead1feff1a7e0833bd3e5
MD5 39d34b668c22cce58f43c02a44d93eaf
BLAKE2b-256 e76b35d2952a80b7c013d383aa7bc1a6ed03ac3ebcbffa3661fa31bb591ef8c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page