Amazon Redshift- write date and time

0

Is there a Boto3 python script available that gives Date and Time, when was last time Table in Amazon Redshift was written (INSERT, UPDATE and DELETE), just need data and time, not the content which was written.

已提問 1 年前檢視次數 195 次
1 個回答
0

In order to extract this information you need to look into system tables. You can call Redshift Data API to run a query against system tables from boto3.

Create a query to extract time & query text from STL_QUERY + STL_QUERYTEXT (Provisioned) or SYS_QUERY_HISTORY (Serverless). Your query would look like SELECT * FROM ... WHERE text LIKE '%INSERT%' AND text LIKE '%mytable%'.

Note that in the example above, mytable may not be the target of INSERT so you need to check the extracted query text manually. If you need full automation, parse the query text in Python using SQL parser library like below. https://github.com/macbre/sql-metadata

AWS
Yota_H
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南