n8n

How to Automate Google Sheets to Postgres Data Sync?

Keep your database in step with your spreadsheet. This setup moves contact style data from Google Sheets into PostgreSQL on a schedule, so teams can work in Sheets while apps read clean records from the database.

A timed trigger runs both data sources at once. It reads rows from a chosen Google Sheet and pulls all rows from a selected PostgreSQL table. The flow keeps only the needed fields first_name, last_name, town, and age. Records are matched by first_name, and the sheet is treated as the source of truth. New names get inserted into the table. Existing names get updated with changed values. This reduces copy and paste work and keeps backend data current for dashboards and internal tools.

To set it up, connect Google Sheets and PostgreSQL, pick the sheet and table, and confirm the match field. You can switch the match field to a unique ID if your data has one. Expect faster updates, fewer errors, and a single source of data for reports and apps. Good fits include syncing event signups, simple CRM lists, and staff directories into a central database.

What are the key features?

  • Scheduled run that checks for changes at regular intervals
  • Reads rows from a specific Google Sheet and tab
  • Splits out only the needed fields first_name, last_name, town, and age
  • Selects all rows from a target PostgreSQL schema and table
  • Compares datasets by first_name and prefers Google Sheets values
  • Inserts brand new records and updates existing records in separate branches

What are the benefits?

  • Reduce manual spreadsheet to database updates from hours to minutes
  • Improve data quality by reducing copy and paste errors by 90%
  • Connect Google Sheets and PostgreSQL in a single scheduled flow
  • Scale to thousands of rows without adding more manual work
  • Keep dashboards and internal tools current on a schedule you control

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Google Sheets and PostgreSQL. See the Tools Required section above for links to create accounts with these services.
  3. Make sure you have edit access to the Google Sheet and read write access to the target PostgreSQL schema and table. Confirm the table has columns for first_name, last_name, town, and age.
  4. Open the Google Sheets node and in the 'Credential to connect with' dropdown click 'Create new credential' then follow the on screen steps. Name the credential clearly, for example 'GSheets Sync'. Choose the document and the sheet tab you want to use.
  5. Open the PostgreSQL nodes (Select Rows, Insert Rows, Update Rows) and for each one choose 'Create new credential' then follow the on screen steps. Add host, port, database, user, and password. Test the connection and give it a clear name like 'Postgres Prod'.
  6. In the Schedule Trigger, set the interval to match your needs, such as every hour. Save the workflow after changing the schedule.
  7. In the Select Rows in Postgres node, choose the correct schema and table and set Return All to true so the compare step sees all current records.
  8. In the Split Out Relevant Fields node, confirm the field list includes first_name, last_name, town, and age. Adjust if your sheet uses different headers that map to your table columns.
  9. Open the Compare Datasets node. Set Input 1 to the Google Sheets branch and Input 2 to the PostgreSQL branch. Confirm merge by fields is first_name and set resolve to prefer Input 1 so sheet values win. If you have a unique key like email or an ID, change the match field here.
  10. In Insert Rows, map each column to the right expression like {{ $json.first_name }}. Use the same table and schema as the Select Rows node.
  11. In Update Rows, map the columns to {{ $json.field }} values and set the update condition to use the same match field you chose in Compare Datasets so updates target the correct row.
  12. Run the workflow once manually and check the PostgreSQL table. Confirm that new rows were inserted and existing rows were updated as expected.
  13. If nothing changes, check that the sheet headers match the field names and that the database column types align with the data in the sheet. Fix any permission issues or column mismatches, then test again.
  14. Turn on the workflow. Watch the next scheduled run to confirm ongoing sync. Adjust the schedule or match field as your data grows.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Google Sheets

Sign up

Free: $0 (Google Sheets API usage has no additional cost; quota limits apply)

PostgreSQL

Sign up

Free: $0 (open-source PostgreSQL License; self-hosted)

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.