Truncate Cloud SQL table using Cloud Admin API

已查看 552 次
跳至第一个未读帖子

Rajesh Sandadi

未读,
2019年5月6日 07:39:292019/5/6
收件人 Google Cloud SQL discuss
Hi Team,

My requirement is to truncate the cloud sql table prior to import CSV data.

Is there any option achieve the same using cloud sql admin API?

Thanks,  

Rajesh Sandadi

未读,
2019年5月9日 07:42:072019/5/9
收件人 Google Cloud SQL discuss
Can someone please tell me how I can do this?

Pavel Ivanov

未读,
2019年5月15日 01:49:572019/5/15
收件人 google-cloud...@googlegroups.com
There is no way to truncate a table (or execute any other statement)
using sql admin API.

Pavel
> --
> 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-d...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/605deec5-d792-4096-9c01-3232fc810af8%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Rajesh Sandadi

未读,
2019年5月16日 00:38:482019/5/16
收件人 Google Cloud SQL discuss
Thank you Pavel. I managed to truncate the table using event scheduler option for everyday at particular time.


On Wednesday, May 15, 2019 at 9:49:57 AM UTC+4, Pavel Ivanov wrote:
There is no way to truncate a table (or execute any other statement)
using sql admin API.

Pavel

On Thu, May 9, 2019 at 4:42 AM Rajesh Sandadi
<rajesh...@emirates.com> wrote:
>
> Can someone please tell me how I can do this?
>
> On Monday, May 6, 2019 at 3:39:29 PM UTC+4, Rajesh Sandadi wrote:
>>
>> Hi Team,
>>
>> My requirement is to truncate the cloud sql table prior to import CSV data.
>>
>> Is there any option achieve the same using cloud sql admin API?
>>
>> Thanks,
>
> --
> 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+unsub...@googlegroups.com.

John Scott Ertel

未读,
2019年5月16日 10:53:472019/5/16
收件人 google-cloud...@googlegroups.com
The SQL Admin API would be to manage instances. Like creating a new instance, editing machine type, etc.

To work with the actual objects in the database you need to execute SQL statements. A pattern for what you want to do would be to:

1. Create a connection object in the language of your choice. 
2. Read the CSV into a data structure.
3. execute truncate SQL statement.
4. execute insert statement. 



--
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-d...@googlegroups.com.


--
John Scott  Ertel, CMA, CPA.
回复全部
回复作者
转发
0 个新帖子