Checks a database table every hour and appends any records it has not copied yet to a Google Sheet.

UsesGoogle SheetsSupabase

Copy new database records to a spreadsheet

Every hour, the workflow reads a table in your Supabase database and appends any record it has not copied before as a new row in a Google Sheet. People who cannot open the database get a live copy of the table in a spreadsheet, and the database itself is only ever read, never changed.

Each row holds the record's id, when it was created, its name and its email. The sheet is the memory: column A holds every copied id, and a record whose id is already there is skipped, so a second run adds nothing new, re-running after a failure is safe, and deleting a row from the sheet has that record copied again. Nothing already in the sheet is overwritten. A record with no id is skipped and reported, since it could never be told apart later, while a record missing a name or email is still copied with that cell left blank.

If the sheet is empty, a heading row is written first. The whole table is read on each run, so it suits tables up to a few thousand rows.

Run every hour.Run every hour.
Set tableName to blank.Set tableName to blank.
Set spreadsheetUrl to blank.Set spreadsheetUrl to blank.
Set sheetName to “Sheet1”.Set sheetName to “Sheet1”.
Google SheetsGoogle SheetsRead column 'A' of sheetName in spreadsheetUrl. Save it as sheetColumn.Read column 'A' of sheetName in spreadsheetUrl. Save it as sheetColumn.
Set copiedKeys to sheetColumn.values.Set copiedKeys to sheetColumn.values.
If copiedKeys is emptyIf copiedKeys is empty
Yes
Google SheetsGoogle SheetsAdd a row to sheetName in spreadsheetUrl.Add a row to sheetName in spreadsheetUrl.
Add “Record ID” to the end of copiedKeys and save it as copiedKeys.Add “Record ID” to the end of copiedKeys and save it as copiedKeys.
No
No steps
SupabaseSupabaseList rows from tableName. Save it as lookup.List rows from tableName. Save it as lookup.
Set records to lookup.rows.Set records to lookup.rows.
Set addedCount to 0.Set addedCount to 0.
For each record in records:For each record in records:
Set idValue to record.id.Set idValue to record.id.
If idValue is emptyIf idValue is empty
Yes
Show in the output: “Skipped a record with no 'id' column - nothing to identify it by.”.Show in the output: “Skipped a record with no 'id' column - nothing to identify it by.”.
Skip to the next item.Skip to the next item.
No
No steps
Set recordKey to “@idValue”.Set recordKey to “@idValue”.
If recordKey is emptyIf recordKey is empty
Yes
Show in the output: “Skipped a record whose 'id' is empty.”.Show in the output: “Skipped a record whose 'id' is empty.”.
Skip to the next item.Skip to the next item.
No
No steps
If copiedKeys contains recordKeyIf copiedKeys contains recordKey
Yes
Skip to the next item.Skip to the next item.
No
No steps
Set createdAt to blank.Set createdAt to blank.
If record.created_at isn't emptyIf record.created_at isn't empty
Yes
Change createdAt to “@record.created_at”.Change createdAt to “@record.created_at”.
No
No steps
Set recordName to blank.Set recordName to blank.
If record.name isn't emptyIf record.name isn't empty
Yes
Change recordName to “@record.name”.Change recordName to “@record.name”.
No
No steps
Set recordEmail to blank.Set recordEmail to blank.
If record.email isn't emptyIf record.email isn't empty
Yes
Change recordEmail to “@record.email”.Change recordEmail to “@record.email”.
No
No steps
If a step below fails, save the error as appendErrorIf a step below fails, save the error as appendError
Try
Google SheetsGoogle SheetsAdd a row to sheetName in spreadsheetUrl.Add a row to sheetName in spreadsheetUrl.
Add recordKey to the end of copiedKeys and save it as copiedKeys.Add recordKey to the end of copiedKeys and save it as copiedKeys.
Add 1 to addedCount.Add 1 to addedCount.
On error
Show in the output: Could not copy record recordKey: appendError as text.Show in the output: Could not copy record recordKey: appendError as text.
Show in the output: Copied addedCount as text new record(s) into the spreadsheet.Show in the output: Copied addedCount as text new record(s) into the spreadsheet.