MySQL Database Schemas/Structures Comparison Script based on 'Python' language.
Usecase :
A) 'db_master1' database is your perfect database which covered schemas & structures like tables, indexes, foreign keys, triggers, routines etc. as per product requirements.
B) 'db_testing1' database is your raw database which covered schemas like tables, indexes, foreign keys, triggers, routines etc. as per product requirements, but raw 'db_testing1' database is missing some schemas as compared to perfect 'db_master1' database due to some reasons.
C) Missing schemas on raw 'db_testing1' database might be :
- New columns on existing tables
- Need to change existing columns definition on existing tables
- Need to change existing columns datatype on existing tables
- New tables on existing database
- New indexes on existing tables
- Need to change existing indexes definition on existing tables
- New triggers on existing tables
- Need to change existing triggers definition on existing tables
- New functions/routines/events on database
- Need to change existing functions/routines/events definition on database
- New views on database
- Need to change existing views definition on database
To overcome from above mentioned problem i have developed an script to solve problem automatically within shorter period of time.
Script Compare :
- Table Attributes
- Table Structure [Column data-type / definition, indexes, foreign keys constraints]
- Table Columns
- Table Indexes
- Table Foreign Key Constraints
- Table Triggers
- DB Routine / Event / Procedure / Function
- DB Views
- Above All Options
Script Benefits :
- User-friendly
- Eliminate mistakes
- Deploy changes from dev, to test, to production
- Find and fix errors caused by differences between databases
- Generate SQL scripts that can be manually edited before running
- Speed up the deployment of new database schema updates
- DB schemas can synchronize between local to local, local to remote, remote to remote.
Check Sample Videos on Youtube Link : https://www.youtube.com/channel/UC30lKncvpa8kKtPsIE3WrrQ
If you like videos then please share it to your friends too. If you / your friends want to use / run this script then put your email id in comment box. I'll share the installation and procedure steps. Don't forget to Like or Subscribe to my youtube channel to get more videos.
Installation process on ubuntu OS version <= 14 [for python2.7] :
- Install 'Lampstack' i.e (php, apache2, mysql version <= 5.5)
Link : https://www.digitalocean.com/community/tutorials/how-to-install-lamp-on-ubuntu-14-04-quickstart - Install 'Python' version 2.7
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python2.7
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python-pip - Install python 'PyMySQL' for python version 2.7
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python-pymysql - Create 'bin' folder in your home directory level & set 774 permission to 'bin' created folder recursively.
- Copy script for python version 2.7 into created 'bin' directory.
Download file name : diffDB2.py - Open terminal and goto created bin directory level. Type 'diffDB2.py' and press 'ENTER' button.
- Go ahead steps-wise with script.
Installation process on ubuntu OS version 18.0 [for python2.7] :
- Install 'Lampstack' i.e (php, apache2, mysql version >= 5.7)
Link : https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-ubuntu-18-04 - After installed mysql and phpmyadmin.
Remove 'ONLY Full Group BY' option permanently.
Remove 'zero in default date' & 'zero in default datetime' option permanently. - Install 'Python' version 2.7
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python2.7
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python-pip - Install python 'PyMySQL' for python version 2.7
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python-pymysql - Create 'bin' folder in your home directory level & set 774 permission to created 'bin' folder recursively.
- Copy script for python version 2.7 into created 'bin' directory.
Download file name : diffDB2.py
- Open terminal and goto created bin directory level. Type 'diffDB2.py' and press 'ENTER' button.
- Go ahead steps-wise with script.
Installation process on ubuntu OS version 18.0 [for python3.6]:
- Install 'Lampstack' i.e (php, apache2, mysql version >= 5.7)
Link : https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-ubuntu-18-04 - After installed mysql and phpmyadmin.
Remove 'ONLY Full Group BY' option permanently.
Remove 'zero in default date' & 'zero in default datetime' option permanently. - Install 'Python' version 3.6
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python3.6
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python3-pip - Install python 'PyMySQL' for python version 3.6
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python3-pymysql - Create 'bin' folder in your home directory level & set 774 permission to created 'bin' folder recursively.
- Copy script for python version 3.6 into created 'bin' directory.
Download file name : diffDB3.py
- Open terminal and goto created bin directory level. Type 'diffDB3.py' and press 'ENTER' button.
- Go ahead steps-wise with script.
Installation process on linux/debian OS version 9 [for python2.7] :
- Install 'Lampstack' i.e (php, apache2, mysql)
Link : https://www.linuxbabe.com/debian/install-lamp-stack-debian-9-stretch - Install phpmyadmin
Run command via terminal : sudo apt-get install phpmyadmin
Link : https://www.youtube.com/watch?v=p08xghuzBwc - Install 'Python' version 2.7
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python2.7
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python-pip - Install python 'PyMySQL' for python version 2.7
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python-pymysql - Create 'bin' folder in your home directory level & set 774 permission to created 'bin' folder recursively.
- Copy script for python version 2.7 into created 'bin' directory.
Download file name : diffDB2.py - Open terminal and goto created 'bin' directory & press 'ENTER' button.
- Type 'python diffDB2.py' and press 'ENTER' button.
- Go ahead steps-wise with script.
Installation process on linux/debian OS version 9 [for python3.6] :
- Install 'Lampstack' i.e (php, apache2, mysql)
Link : https://www.linuxbabe.com/debian/install-lamp-stack-debian-9-stretch - Install phpmyadmin
Run command via terminal : sudo apt-get install phpmyadmin
Link : https://www.youtube.com/watch?v=p08xghuzBwc - Install 'Python' version 3.6
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python3.6
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python3-pip - Install python 'PyMySQL' for python version 3.6
Run command via terminal : sudo apt-get update
Run command via terminal : sudo apt-get install python3-pymysql - Create 'bin' folder in your home directory level & set 774 permission to created 'bin' folder recursively.
- Copy script for python version 3.6 into created 'bin' directory.
Download file name : diffDB3.py - Open terminal and goto created 'bin' directory & press 'ENTER' button.
- Type 'python3 diffDB3.py' and press 'ENTER' button.
- Go ahead steps-wise with script.
Installation process on centos OS version 6 [for python2.7] :
- Install 'Lampstack' i.e (php, apache2, mysql)
Link : https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-6 - Install 'Python' version 2.7
Link : https://tecadmin.net/install-python-2-7-on-centos-rhel/ - Install 'Pip' for python version 2.7
Run command via terminal : curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
Run command via terminal : python2.7 get-pip.py --user - Install python 'PyMySQL' for python version 2.7
Link : https://unix.stackexchange.com/questions/254294/make-python-2-7-the-default-python-in-centos-making-an-alias-didnt-work Run command via terminal : sudo rm -r /usr/bin/python
Run command via terminal : sudo ln -s /usr/local/bin/python2.7 /usr/bin/python
Run command via terminal : pip install pymysql --user - Create 'bin' folder in your home directory level & set 774 permission to created 'bin' folder recursively.
- Copy script for python version 2.7 into created 'bin' directory.
Download file name : diffDB2.py - Open terminal and goto created bin directory level. Type 'python2.7 diffDB2.py' and press 'ENTER' button.
- Go ahead steps-wise with script.
Installation process on centos OS version 6 [for python3.6] :
- Install 'Lampstack' i.e (php, apache2, mysql)
Link : https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-6 - Install 'Python' version 2.7
Link : https://tecadmin.net/install-python-3-6-on-centos/ Link : https://danieleriksson.net/2017/02/08/how-to-install-latest-python-on-centos/ - Install 'Pip' for python version 3.6
Run command via terminal : wget https://bootstrap.pypa.io/get-pip.py
Run command via terminal : python3.6 get-pip.py --user - Install python 'PyMySQL' for python version 2.7
Link : https://unix.stackexchange.com/questions/254294/make-python-2-7-the-default-python-in-centos-making-an-alias-didnt-work Run command via terminal : sudo rm -r /usr/bin/python
Run command via terminal : sudo ln -s /usr/local/bin/python3.6 /usr/bin/python
Run command via terminal : pip3.6 install pymysql --user - Create 'bin' folder in your home directory level & set 774 permission to created 'bin' folder recursively.
- Copy script for python version 3.6 into created 'bin' directory.
Download file name : diffDB3.py - Open terminal and goto created bin directory level. Type 'python3.6 diffDB3.py' and press 'ENTER' button.
- Go ahead steps-wise with script.
Installation process on windows OS version 10 [for python2.7] :
- Install 'XAMPP'
Link : https://pureinfotech.com/install-xampp-windows-10/ - Install 'Python' version 2.7
Link : https://datascience.com.co/how-to-install-python-2-7-and-3-6-in-windows-10-add-python-path-281e7eae62a - Open command prompt and Goto directory 'c:/python27/script' and press 'ENTER' button
- Type this 'pip install pymysql' command and press 'ENTER' button
- Start 'XAMPP' server
- Copy mysql diff db script for python version 2.7 into your 'Downloads' directory
Download file name : diffDB2.py - Open command prompt and goto 'Downloads' directory and type 'diffDB2.py' command and press 'ENTER' button
- Go ahead steps-wise with script.
Installation process on windows OS version 10 [for python3.6] :
- Install 'XAMPP'
Link : https://pureinfotech.com/install-xampp-windows-10/ - Install 'Python' version3.6
Link : https://datascience.com.co/how-to-install-python-2-7-and-3-6-in-windows-10-add-python-path-281e7eae62a - Open command prompt and Goto directory 'c:/python36/script' and press 'ENTER' button
- Type this 'pip install pymysql' command and press 'ENTER' button
- Start 'XAMPP' server
- Copy mysql diff db script for python version 3.6 into your 'Downloads' directory
Download file name : diffDB2.py - Open command prompt and goto 'Downloads' directory and type 'diffDB3.py' command and press 'ENTER' button
- Go ahead steps-wise with script.
Any suggestions, improvements, facing issues etc. Contact on given below details.
Author Name : Chirag D Jain
Mobile & What's App : 91+ 9975967186
Email : [email protected]
Country : India