0

I have a table in bigquery that I want to continuously replicate into a google cloud postgres table and be able to query it from the postgres instance. What is the easiest way to do this? I am hoping to create a cronjob to run a query to create the table in postgres

Something like....

CREATE OR REPLACE TABLE postgres_server.table123 as select * from bigquery.table123;

Is this possible?

1 Answer 1

1

I don't think there is a direct way to do this replicate between Bigquery and Cloud SQL.

To copy data from Big query to Cloud SQL one option I could think of is Export/Import:

  1. First export the data in CSV format in GCS and then import the same in cloud sql. Also because of the export limitation in BQ, for tables larger than 1 GB we need to export to multiple files into GCS bucket
  2. Import Operation into Cloud SQL, we can use psql copy command

Sample Copy Command which we can run from VM(VM instance to have access to GCS bucket Source and Target Post Gres): gsutil cat gs://<bucket_name>/<csv_filename> | psql -h <CLOUDSQL_IP> -d -U -c "\copy from stdin with (format csv)"

[1] https://cloud.google.com/bigquery/docs/exporting-data [2] https://www.postgresql.org/docs/13/sql-copy.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.