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:
Select or create a Cloud Platform project using the Cloud Console.
Enable billing for your project, as described in the Google Cloud documentation.
Enable the API, as described in the Cloud Console documentation.
Install API libraries via pip.
pip install 'apache-airflow[google]'Detailed information is available for Installation.
Upload data from SQL to Google Sheets¶
To upload data from and Database using SQL to Google Spreadsheet you can use the
SQLToGoogleSheetsOperator
.
upload_gcs_to_sheet = SQLToGoogleSheetsOperator(
task_id="upload_sql_to_sheet",
sql=SQL,
sql_conn_id=DB_CONNECTION,
database="test_db",
spreadsheet_id=SPREADSHEET_ID,
)
You can use Jinja templating with
sql
, spreadsheet_id
, spreadsheet_range
, impersonation_chain
.