tests.system.providers.google.cloud.sql_to_sheets.example_sql_to_sheets

Required environment variables: ` DB_CONNECTION = os.environ.get("DB_CONNECTION") SPREADSHEET_ID = os.environ.get("SPREADSHEET_ID", "test-id") `

First, you need a db instance that is accessible from the Airflow environment. You can, for example, create a Cloud SQL instance and connect to it from within breeze with Cloud SQL proxy: https://cloud.google.com/sql/docs/postgres/connect-instance-auth-proxy

# DB setup Create db: ` CREATE DATABASE test_db; `

Switch to db: ` \c test_db `

Create table and insert some rows ` CREATE TABLE test_table (col1 INT, col2 INT); INSERT INTO test_table VALUES (1,2), (3,4), (5,6), (7,8); `

# Setup connections db connection: In airflow UI, set one db connection, for example “postgres_default” and make sure the “Test” at the bottom succeeds

google cloud connection: We need additional scopes for this test scopes: https://www.googleapis.com/auth/spreadsheets, https://www.googleapis.com/auth/cloud-platform

# Sheet Finally, you need a Google Sheet you have access to, for testing you can create a public sheet and get its ID.

# Tear Down You can delete the db with ` DROP DATABASE test_db; `

Module Contents

tests.system.providers.google.cloud.sql_to_sheets.example_sql_to_sheets.ENV_ID[source]
tests.system.providers.google.cloud.sql_to_sheets.example_sql_to_sheets.DB_CONNECTION[source]
tests.system.providers.google.cloud.sql_to_sheets.example_sql_to_sheets.SPREADSHEET_ID[source]
tests.system.providers.google.cloud.sql_to_sheets.example_sql_to_sheets.DAG_ID = 'example_sql_to_sheets'[source]
tests.system.providers.google.cloud.sql_to_sheets.example_sql_to_sheets.SQL = 'select col2 from test_table'[source]
tests.system.providers.google.cloud.sql_to_sheets.example_sql_to_sheets.upload_gcs_to_sheet[source]
tests.system.providers.google.cloud.sql_to_sheets.example_sql_to_sheets.test_run[source]

Was this entry helpful?