Keep a spreadsheet and a database in step, automatically
Mirror rows between Google Sheets and Postgres in both directions, so the team that lives in a spreadsheet and the systems that live in a database never quietly drift apart.
What this looks like
One step on screen at a time. Read it, do it, tap Next.
Keep a spreadsheet and a database in step, automatically
Step 1 of 13
Start with a schedule, not a live trigger
Create a workflow and add a Schedule Trigger running every 15 minutes. Polling on a schedule is simpler and safer than trying to react instantly to spreadsheet edits.
Checkpoint
A Schedule Trigger sits on the canvas, currently disabled.
Before you begin
Tick these off as you sort them. Stopping halfway to create an account is how a fifteen-minute build becomes an hour.
0 of 9 ready
Ticks are saved on this device, so you can come back to them.
- Have ready
Same column names as the spreadsheet plus an id primary key and an updated_at timestamp column, which this workflow relies on to detect changes.
- Credential
Host, port, database name, user and password, with network access from n8n — check firewall rules if your database is on a private network.
- Have ready
Row order in a spreadsheet is not a reliable identifier. Add an explicit ID column if the sheet doesn't already have one, and never let people delete it.
- Account
Used both to read changes and to write updates back when the database side changes first.
- Know-how
Decide now, on paper, whether the sheet or the database is the source of truth when both change the same row before a sync runs. This walkthrough assumes most recent updated_at wins.
- Time
Two-way sync is the trickiest pattern in this library. Build and test one direction fully before adding the other.
The basics — ticked once, remembered everywhere
- Account
Either the hosted version or a self-hosted install. Everything here works the same on both — the only visible difference is the shape of your webhook URLs.
Create a workspace - Know-how
Adding a node, connecting two of them, and pressing Execute. If any of that is new, the free primer covers it in about ten minutes.
- Credential
You will paste at least one secret during setup. A password manager beats a notes app, and it stops you pasting a live key into a chat window by accident.
The shape of the workflow
The nodes you will end up with, left to right, in the order you add them.
4 things to set here- 1Schedule Trigger — the trigger — everything starts here
- 2Google Sheets — Read every row currently in the sheet
- 3Postgres — Read every row currently in Postgres
- 4Merge — Merge the two sources by ID
Skip the node hunting
Import a starter file with every node for this build already on the canvas, named after its step and wired in order, each one carrying a sticky note with the values to enter. You still connect your own accounts and fill the fields — that is what the walkthrough takes you through — but you never start at a blank canvas.
In n8n: Workflows → Import from file.
What you will build
Jump straight to any step, or print the list and tick it off beside your n8n tab.
- 1Start with a schedule, not a live trigger
- 2Read every row currently in the sheet
- 3Read every row currently in Postgres
- 4Merge the two sources by ID
- 5Work out which side is newer
- 6Push newer sheet rows into Postgres
- 7Push newer database rows into the sheet
- 8Handle brand-new rows on either side
- 9Log conflicts instead of guessing
- 10Enable the schedule and watch the first few runs
- 11Edit one row only in the sheet
- 12Edit one row only in Postgres
- 13Edit the same row on both sides before a sync runs
If something goes wrong
Everything ready?
Start walkthrough