Airflow Summit 2025 is coming October 07-09. Register now for early bird ticket!

SQL to Google Sheets Transfer Operators

With Google Sheets, everyone can work together in the same spreadsheet at the same time. Use formulas functions, and formatting options to save time and simplify common spreadsheet tasks.

Prerequisite Tasks

To use these operators, you must do a few things:

Upload data from SQL to Google Sheets

To upload data from and Database using SQL to Google Spreadsheet you can use the SQLToGoogleSheetsOperator.

tests/system/google/cloud/sql_to_sheets/example_sql_to_sheets.py[source]

upload_sql_to_sheet = SQLToGoogleSheetsOperator(
    task_id="upload_sql_to_sheet",
    sql=SQL_SELECT,
    sql_conn_id=CONNECTION_ID,
    database=DB_NAME,
    spreadsheet_id="{{ task_instance.xcom_pull(task_ids='create_spreadsheet', key='spreadsheet_id') }}",
    gcp_conn_id=SHEETS_CONNECTION_ID,
)

You can use Jinja templating with sql, spreadsheet_id, spreadsheet_range, impersonation_chain.

Was this entry helpful?