Export CloudSQL to Bigquery

96 views
Skip to first unread message

Rajesh Golla

unread,
May 26, 2021, 9:25:44 AM5/26/21
to Google Cloud SQL discuss
Hi,

I know we can use cloud functions.

But I am new to GCP.

Is there any sample code to schedule data load from cloudsql to BigQuery.

Thanks in advance.

Alexis (Google Cloud Support)

unread,
May 27, 2021, 10:28:58 AM5/27/21
to Google Cloud SQL discuss
Hi,

The easiest method is to use Federated queries[1], which allows you to read data from Cloud SQL as if it were in BigQuery.

The sample code you are looking for is scattered across different documents. For example, as as CSV export from SQL with Cloud Scheduler here[2]. And then load the CSV data from a bucket[3] into Big Query.

Then there's also sample code to write streams using Big Query's write API[4]. More about streaming data into BigQuery here[5].

As you can see, there are a lot of possibilities and all these code samples can be used on Cloud Functions. I think you need to decide first how you will export, plus also in what format and when. However, if appropriate to your workflow, none of this needs to be done if you just use Federated Queries. Federated Queries is the simplest method without impact on performance since BigQuery is an aggregator of sort that uses the infrastructure to run queries[6].

Reply all
Reply to author
Forward
0 new messages