3
votes

I have a SQL instance which has a DB into which I will be importing some data using gcloud sql import ....

Thereafter, I want to run a list of INSERT queries to insert data into tables in that DB.

However, I am not able to find a nice way to do this via the command line as something that can potentially be automated via a script - something like, gcloud sql execute <query> or equivalent - and it seems like the only way to do it is by connecting to the the instance (via gcloud sql connect or sql proxy) and manually executing each INSERT query in the interactive SQL CLI.

Does anybody know if there is a better way to do this? I'm not clear on whether or not gcloud supports this type of functionality.

1

1 Answers

0
votes

By the moment gcloud sql is only used for create and manage instances on Cloud SQL [1], as you mentioned the only way for execute queries or scripts is throught gcloud sql connect.

You can create a feature request for this task through issue tracker [2].

[1] https://cloud.google.com/sdk/gcloud/reference/sql [2] https://developers.google.com/issue-tracker