Google Cloud BigQuery Transfer Operator to MySQL¶
Google Cloud BigQuery is Google Cloud’s serverless data warehouse offering. MySQL is an open-source relational database management system. This operator can be used to copy data from a BigQuery table to MySQL.
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.
Operator¶
Copying data from one BigQuery table to another is performed with the
BigQueryToMySqlOperator
operator.
Use Jinja templating with
target_table_name
, impersonation_chain
, dataset_id
, table_id
to define values dynamically.
You may use the parameter selected_fields
to limit the fields to be copied (all fields by default),
as well as the parameter replace
to overwrite the destination table instead of appending to it.
For more information, please refer to the links above.
Transferring data¶
The following Operator copies data from a BigQuery table to MySQL.
bigquery_to_mysql = BigQueryToMySqlOperator(
task_id="bigquery_to_mysql",
dataset_table=f"{DATASET_NAME}.{TABLE}",
target_table_name=destination_table,
replace=False,
)
Reference¶
For further information, look at: