MySQL to Excel when new data is added to MySQL

I have a MySQL database that collects form entries from an app. I want to capture the MySQL entries and send them to an Excel sheet. Whenever a new row is added to the MySQL database, it should add the row to the Excel sheet.

I’ve been able to set up a connection between the MySQL database and Excel and add all the MySQL entries to the Excel sheet, but I’m not sure how to set it up to check for new entries in the MySQL database and then only write those entries as a new row into the Excel sheet.

I’d like to outsource this to get it set up properly.

Can you capture the process of creating new entries in the MySQL database table and use that as the trigger for a scenario? That will be the most elegant, the simplest, and the most impactful solution.


Do you have a primary key used in the MySQL database table of your interest?

If so, you can keep track of the new entries in the database through the primary key and pull them into the excel sheet (or google sheets) at regular or defined times at Hopefully it is a monotonously increasing value. If not a lookup table will be needed to be kept up, updated, and compared against.

If there is no primary key, it is tough but not insurmountable. You can try defining one in the database, making a composite field as primary key. if you are not allowed to change the database, life will start getting harder and harder.

You can check at MySQL with the following command at MySQL. The example shows a composite field defined as the unique combination of column_A AND column_B.

| Table | Create Table …|
| foobar | CREATE TABLE foobar (
column_A int(10) unsigned NOT NULL,
column_B int(10) unsigned NOT NULL,
PRIMARY KEY (column_A,column_B),
KEY column_B (column_B)

Note that you will have some impact on the database with the queries that you will run.

1 Like