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.

질문됨 일 년 전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
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인