Tuesday, January 9, 2018

[google-cloud-sql-discuss] Re: accessing cloud storage from cloud sql

Hello Biraj

It seems, it is not possible through the SQL command. However, you can use 'gcloud' command to export the data the table data from Cloud SQL instance to the Google cloud storage bucket. Here is the documentation link for the command. 

Example commands: 
[1]
gcloud sql instances export <DATABASE_INSTANCE> \      gs://<CLOUD_STORAGE_BUCKET>/export.sql.gz \      --database <DATABASE_NAME>  [2]  
gcloud sql instances export <DATABASE_INSTANCE> gs://<CLOUD_STORAGE_BUCKET>/filename.csv --database <DATABASE_NAME> -t <table-name> 

Also can check this thread as the reference. 

Note: Cloud SQL instance service-account must have appropriate access to the bucket to that service account in order for the export/import to work. You can get the service-account of the SQL instance using the command: gcloud sql instances describe instance-name or from the Cloud SQL instance overview page. 


On Tuesday, January 9, 2018 at 12:04:15 PM UTC-5, BIRAJ RATH wrote:
Is there a way in which we can export the content of a cloud sql table to cloud storage (as CSV) using sql commands? 

I understand there is an export option using which this can be done but i am wondering can we do that by specifying the bucket name and  file name in the sql command itself. 

regards
Biraj

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/a09f8d52-7c1d-48d6-a900-684026a6ea00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment