MySQL To Google Cloud Storage Operator¶
The Google Cloud Storage (GCS) service is used to store large data from various applications. This page shows how to copy data from MySQL to GCS.
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.
MySQLToGCSOperator¶
MySQLToGCSOperator
allows you to upload
data from MySQL database to GCS.
When you use this operator, you can optionally compress the data being uploaded to gzip format.
Below is an example of using this operator to upload data to GCS.
upload_mysql_to_gcs = MySQLToGCSOperator(
task_id="mysql_to_gcs", sql=SQL_SELECT, bucket=BUCKET_NAME, filename=FILE_NAME, export_format="csv"
)
Reference¶
For further information, look at: * MySQL Documentation * Google Cloud Storage Documentation