Checks a database table every hour and appends any records it has not copied yet to a Google Sheet.
Uses
Google Sheets
Supabase
Copy new database records to a spreadsheet
tableName to blank.Set tableName to blank.spreadsheetUrl to blank.Set spreadsheetUrl to blank.sheetName to Sheet1.Set sheetName to Sheet1.sheetName in spreadsheetUrl. Save it as sheetColumn.Read column 'A' of sheetName in spreadsheetUrl. Save it as sheetColumn.copiedKeys to sheetColumn.values.Set copiedKeys to sheetColumn.values.copiedKeys is emptyIf copiedKeys is emptyYes
sheetName in spreadsheetUrl.Add a row to sheetName in spreadsheetUrl.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
tableName. Save it as lookup.List rows from tableName. Save it as lookup.records to lookup.rows.Set records to lookup.rows.addedCount to 0.Set addedCount to 0.record in records:For each record in records:idValue to record.id.Set idValue to record.id.idValue is emptyIf idValue is emptyYes
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..No
No steps
recordKey to idValue.Set recordKey to idValue.recordKey is emptyIf recordKey is emptyYes
Skipped a record whose 'id' is empty..Show in the output: Skipped a record whose 'id' is empty..No
No steps
copiedKeys contains recordKeyIf copiedKeys contains recordKeyYes
No
No steps
createdAt to blank.Set createdAt to blank.record.created_at isn't emptyIf record.created_at isn't emptyYes
createdAt to record.created_at.Change createdAt to record.created_at.No
No steps
recordName to blank.Set recordName to blank.record.name isn't emptyIf record.name isn't emptyYes
recordName to record.name.Change recordName to record.name.No
No steps
recordEmail to blank.Set recordEmail to blank.record.email isn't emptyIf record.email isn't emptyYes
recordEmail to record.email.Change recordEmail to record.email.No
No steps
appendErrorIf a step below fails, save the error as appendErrorTry
sheetName in spreadsheetUrl.Add a row to sheetName in spreadsheetUrl.recordKey to the end of copiedKeys and save it as copiedKeys.Add recordKey to the end of copiedKeys and save it as copiedKeys.addedCount.Add 1 to addedCount.On error
recordKey: appendError as text.Show in the output: Could not copy record recordKey: appendError as text.addedCount as text new record(s) into the spreadsheet.Show in the output: Copied addedCount as text new record(s) into the spreadsheet.