Database Comparer is a GUI-based Python application that allows users to track and compare changes in a MySQL database. It captures the state of all tables at a given point in time, compares them to the latest database state, and highlights differences in data. The tool also provides the ability to export comparison results to a CSV file for further analysis.
- ✅ Capture Initial Database State – Fetches and stores the state of all tables in the connected database.
- ✅ Compare Database Changes – Identifies added, removed, and modified records and fields.
- ✅ User-Friendly Interface – Built with
Tkinter
, providing an intuitive experience. - ✅ CSV Export – Exports differences into a
.csv
file for documentation or further analysis. - ✅ Multi-threading Support – Prevents UI freezing by executing database operations in separate threads.
- ✅ Configurable Database Connection – Uses
config.ini
to manage MySQL connection details.
Before running the script, ensure you have the following installed:
- Python 3.x
mysql-connector-python
tkinter
(built-in with Python)configparser
Install missing dependencies using:
pip install mysql-connector-python
-
Clone the repository:
git clone https://github.com/saymonn37/MySQL-Comparer.git cd MySQL-Comparer
-
Create a
config.ini
file in the root directory with the following structure:[mysql] host = your_mysql_host user = your_mysql_user password = your_mysql_password database = your_database_name
-
Run the script:
python3 database_comparer.py
- Fetch State – Click the "Fetch State" button to capture the initial database state.
- Modify Database Data – Make changes to the database through SQL or an external application.
- Compare States – Click "Compare States" to analyze differences.
- Export to CSV – Save comparison results by clicking "Export to CSV".
- Clear All – Reset the state tracking.
The application consists of:
- Control Panel: Buttons for fetching state, comparing changes, exporting results, and clearing data.
- Comparison Table: Displays detected changes with the following columns:
- Table Name – The affected database table.
- ID – The primary key or first column value.
- Column – The column number.
- Column Name – Name of the modified column.
- Old Value – Previous value before modification.
- New Value – Updated value.
If a row is modified in a table:
Table | ID | Column | Column Name | Old Value | New Value |
---|---|---|---|---|---|
users | 1 | 2 | username | JohnDoe | John_Doe |
orders | 5 | 4 | status | pending | shipped |
- If MySQL credentials are incorrect, an error message will be displayed.
- If no database state is captured before comparison, an alert is shown.
- If an error occurs during CSV export, the user will be notified.
- Add support for other database types (PostgreSQL, SQLite).
- Enhance UI for a better user experience.
- Implement logging for troubleshooting.
Issue | Solution |
---|---|
GUI not opening | Ensure Tkinter is installed. Run python3 -m tkinter to check. |
Database connection error | Verify credentials in config.ini . |
No changes detected | Ensure modifications were made to the database. |
This project is open-source under the MIT License.
Developed by Saymonn. Contributions and feedback are welcome!