Skip to main content

Google Sheets Destination

Write records to a Google Sheets spreadsheet (overwrite or append).

YAML Example​

destination:
type: google_sheets
spreadsheet_id: "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms"
sheet: "Sheet1"
mode: overwrite
credentials_env: GOOGLE_SHEETS_CREDENTIALS

Configuration​

FieldTypeDefaultDescription
type"google_sheets"—Required
spreadsheet_idstring—Google Sheets ID (from the URL)
sheetstring"Sheet1"Sheet tab name
modeoverwrite|appendoverwriteWrite mode
credentials_pathstring | nullnullPath to service account JSON keyfile
credentials_envstring | nullnullEnv var containing keyfile path

Authentication​

  1. Create a Service Account in Google Cloud
  2. Download the JSON keyfile
  3. Share the spreadsheet with the service account email
  4. Set the env var:
export GOOGLE_SHEETS_CREDENTIALS="/path/to/service-account.json"

Common Patterns​

Overwrite (replace all data each run):

mode: overwrite
# clears the sheet and writes fresh data with headers

Append (add new rows):

mode: append
# adds rows after existing data, no header row added

Incremental sync to a specific tab:

sheet: "Daily Report"
mode: append
sync:
mode: incremental
cursor_field: created_at

Notes​

  • Requires pip install drt-core[sheets] (uses gspread + google-auth)
  • overwrite clears the sheet first, then writes headers + data
  • append adds rows without clearing — combine with mode: incremental to avoid duplicates
  • Columns are positional. The first batch of a run fixes the column set (the union of every record's keys, in first-seen order); a record missing a column gets an empty cell. A later batch that introduces a column the first batch did not have fails the sync with a column mismatch error instead of dropping data. If a source has sparse fields that may first appear late, raise sync.batch_size so the first batch sees them.
  • Google Sheets API has a quota of 300 requests/minute per project
  • spreadsheet_id is the long string in the spreadsheet URL: https://docs.google.com/spreadsheets/d/{spreadsheet_id}/edit