2

I have a table stored in BigQuery and I would like to create a copy of this table+data within a PostgreSQL database. This PostgreSQL is in Google Cloud SQL.

This export will occur daily, that is, the same table will be exported daily to PostgreSQL, so the ideal solution can be automated/repeated, rather than a manual solution.

How can I achieve this?

2
  • The title of this question is incorrect. You want to export a table. There is a huge difference between exporting a table and exporting data. I'm mainly interested in exporting the entire database and found your question as well as the answer useless. Commented Jan 10, 2024 at 15:46
  • 1
    @Ash The title is not incorrect. Your interpretation is correct. Data != database. Data is a vague mass noun, so could refer to anything, which OP defines in their question. But you wanted more than just 'data' from the outset; you wanted an entire database. That's not OP's fault nor the answerer's fault. The question and answer are clear and correct. Commented Jan 11, 2024 at 16:38

1 Answer 1

1

You can use the BigQuery and CloudSQL APIs to do that, exporting the BQ table as CSV to cloud storage and then importing the file as table in CloudSQL. Then you can automate this process using Cloud Functions + Cloud Scheduler (or even Cloud DataFlow for more complex pipelines).

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

2 Comments

I read that Bigquery has the "EXPORT DATA" command which allows you to export data to a file, for example CSV. Do you consider this command as a solution to export data using only SQL syntax? That is, without using Python or another language? On the part of Postgres, I don't know if there is any SQL command from Postgres that would allow reading a CSV file directly from Cloud Storage
This answer would be improved by showing, at least in part, how to "use the Big Query and Cloud SQL APIs to do that".

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.