Scheduled Database to Spreadsheet Synchronization - n8n Workflow

Use this powerful n8n workflow template to reliably synchronize new MySQL database records to Google Sheets automatically every 15 minutes. This n8n workflow uses an update flag to prevent duplicate entries, ensuring data integrity.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Data teams needing reliable, automated database replication.
Operations specialists who use Google Sheets for reporting based on live database data.
Developers seeking proven n8n templates for idempotent synchronization logic.
Anyone looking to utilize a Schedule n8n trigger for time-based data operations.

Overview

Maintaining consistency between a backend database and frontend reporting tools like Google Sheets is critical. This specific n8n workflow solves the problem of unreliable data synchronization by implementing an idempotent schedule. It uses a specific logic within the MySQL n8n node to only select rows that have not yet been synced (where the 'sync' column equals 0). After successfully appending the data to Google Sheets, the workflow immediately updates those specific records, setting the 'sync' column to 1. This prevents the same records from being processed repeatedly in subsequent runs, offering a robust and reliable n8n solution. This n8n node sequence ensures efficiency and data quality.

How it Works

The entire process is initiated by a time-based n8n trigger.


  1. Scheduled Execution: The n8n workflow begins every 15 minutes using the Schedule Trigger n8n node.

  2. Data Extraction: The MySQL n8n node queries the fifa25_customers table, specifically fetching only records where the sync column is set to 0. This ensures we only handle new, unsynced data.

  3. Conditional Check: An If n8n node checks the length of the returned data. If zero records are found, the workflow gracefully stops. If data exists, the process continues.

  4. Data Appending: The Google Sheets n8n node appends the fetched data (ID, name, email, phone, etc.) to the specified spreadsheet document.

  5. Status Update: Immediately following the successful append, a second MySQL n8n node executes. This n8n node updates the original records in the database, setting the sync column to 1, keyed by the record ID. This idempotent mechanism ensures that this specific n8n workflow will not process these records again.

Installation Guide

To deploy this powerful n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON code and import it directly into your n8n instance using the workflow import tool.

  2. MySQL Credential Setup: Locate the MySQL n8n node (both 'Select rows' and 'Update rows'). You must configure and connect your MySQL database credentials.

  3. Google Sheets Credential Setup: Locate the Google Sheets n8n node ('Append row in sheet'). Configure your Google Sheets OAuth2 API credentials.

  4. Database Preparation: Ensure your target MySQL table (fifa25_customers in this example) includes a column named sync (typically an integer field) used by this specific n8n node logic for tracking synchronization status.

  5. Activation: Once credentials are set and the database structure matches the requirements, activate the n8n workflow. The n8n trigger will begin running on the set schedule.

Node Details

Schedule Trigger Every n Mins (n8n trigger): This is the starting n8n node, configured to run the entire n8n workflow every 15 minutes, providing reliable, recurring execution.
Select rows from a table (MySQL n8n node): Connects to the database and retrieves up to 50 customer records where sync is equal to 0. This targets only new data waiting for synchronization.
Check if new record returned (If n8n node): A core flow control n8n node that checks if the MySQL query returned any data. It prevents unnecessary execution of downstream steps if no new records exist.
Append row in sheet (Google Sheets n8n node): Maps specific fields from the MySQL output (like id, name, email, phone) and appends them as a new row to the specified Google Sheet.


  • Update rows in a table (MySQL n8n node): Crucial for preventing duplicates. This n8n node sets the sync column to 1 for all successfully transferred records, ensuring the Schedule n8n trigger doesn't process them again in the next run.

Related n8n Workflows

Free

Nodes: 6 Nodes
Updated: December 26 2025
View all
Created by
Ahmed Saadawi
Ahmed Saadawi

Featured*