Skip to content

bigfunctions > upload_table_to_gsheet

upload_table_to_gsheet

Signature

upload_table_to_gsheet(table_or_view_or_query, max_rows, spreadsheet_url, worksheet_name, write_mode)

Description

Upload data from table_or_view_or_query to Google Sheet (maximum max_rows rows will be uploaded).

  1. 💡 For this to work, share your Google Sheet in edit mode to 749389685934-compute@developer.gserviceaccount.com
  2. write_mode controls what is done if a worksheet with worksheet_name already exists. It must be one of:
    • write_truncate: if the sheet already exists, it will be recreated.
    • write_append: if the sheet already exists, data will be appended to it.
    • raise_error: if the sheet already exists, an error will be raised.
    • do_nothing: if the sheet already exists, nothing will be done.
    • null: same as write_truncate

Examples

1. upload 1000 rows from a table

call bigfunctions.eu.upload_table_to_gsheet(
  'eu.sales', 
  1000, 
  'https://docs.google.com/spreadsheets/d/xxxxxxxxx', 
  'my worksheet', 
  'write_truncate');
call bigfunctions.us.upload_table_to_gsheet(
  'us.sales', 
  1000, 
  'https://docs.google.com/spreadsheets/d/xxxxxxxxx', 
  'my worksheet', 
  'write_truncate');
call bigfunctions.europe_west1.upload_table_to_gsheet(
  'europe_west1.sales', 
  1000, 
  'https://docs.google.com/spreadsheets/d/xxxxxxxxx', 
  'my worksheet', 
  'write_truncate');

screenshot

2. with a query

call bigfunctions.eu.upload_table_to_gsheet(
  '(select 1 as foo)', 
  null, 
  'https://docs.google.com/spreadsheets/d/xxxxxxxxx', 
  'my worksheet', 
  'write_truncate');
call bigfunctions.us.upload_table_to_gsheet(
  '(select 1 as foo)', 
  null, 
  'https://docs.google.com/spreadsheets/d/xxxxxxxxx', 
  'my worksheet', 
  'write_truncate');
call bigfunctions.europe_west1.upload_table_to_gsheet(
  '(select 1 as foo)', 
  null, 
  'https://docs.google.com/spreadsheets/d/xxxxxxxxx', 
  'my worksheet', 
  'write_truncate');