dbForge Data Compare for MySQL allows you to schedule or automate the generation of the comparison report. You can use a task scheduler tool to schedule the report generation.
In our example, we consider the following case: Suppose that you are a Business Analyst. Every Monday you receive backups of MySQL databases which you need to deploy and then compare their data. In addition, you need to compare only tables and views that have film in their names. The comparison should result in the report in a .csv file format.
For demo purposes, we will compare two MySQL databases: sakila and sakila_test. The generation of the comparison report will include the following steps:
1. Create a .bat file to deploy the databases.
3. Create a .bat file to compare the databases.
4. Generate the report in a .csv file format.
5. Schedule the comparison report generation
1. On the toolbar, click Execute Large Script.
2. In the Execute Script Wizard that opens, specify a path to a .sql file that creates a database.
3. Click Save Command Line to generate a .bat file for the database deployment.
4. Optional: In the Command line execution file settings dialog, click Validate to verify that the settings to manage the .bat file are valid.
5. To save the file settings, click Save. In the Save As dialog, specify the file location, enter the file name, and then click Save.
Repeat the same steps to create .bat files to deploy data and schema for the database to be compared.
After you have created the .bat files, you need to run them to deploy the databases. Then, you can compare the databases using the .bat file created with the help of dbForge Data Compare for MySQL.
1. On the toolbar, click New Data Comparison.
2. In the New Data Comparison > Source and Target wizard that opens, do the following:
3. On the Options page, select the following checkboxes:
4. Click Save Command Line to open the wizard for report generation.
5. In the Command line execution file settings wizard that opens, select the Report checkbox and do the following:
6. To save the .bat file, click Save. In the Save As dialog, specify the file location, enter the file name, and then click Save.
After the .bat file has been created, we can execute it to generate the comparison report in a .csv file format. To open the report, navigate to the folder that stores the report. Data Compare for MySQL generates a separate CSV file for each selected table or view, as well as creates a SummaryResults file.
We can automate the process of the comparison report generation with the help of Windows Task Scheduler and schedule the report generation at a specific period of time. To do that, perform the following steps:
1.Open Task Scheduler.
2. In the Task Scheduler > Actions pane, click Create Basic Task to create a scheduled task.
3. In the Create Basic Task Wizard dialog that opens, specify the name and optional description of the task and then click Next.
4. On the Trigger page, select Weekly and then click Next.
5. On the Weekly page, set time to start the task and then click Next.
6. On the Action page, click Start a program to schedule a program to start automatically and then click Next.
7. On the Start a Program page, click Browse to select the .bat file you have created in the Data Comparison Wizard and then click Next.
There are optional fields that you can set:
8. On the Finish tab, verify the settings and click Finish.
The task will be displayed in the Active Tasks section.