如何在 aws quicksight 中安排或自动化数据集刷新

How to schedule or automate dataset refresh in aws quicksight

有哪些选项可用于安排或自动刷新 quicksight SPICE 数据集?

是否有任何 API 可用于自动刷新 spice 数据集?最好使用 python.

你有两个选择,

- 使用最新版 boto3 中提供的 API 服务

使用'create_ingestion' method to initiate dataset refresh, and use 'describe_ingestion'检查刷新状态

import boto3
import time
import sys
client = boto3.client('quicksight')
response = client.create_ingestion(DataSetId='<dataset-id>',IngestionId='<ingetion-id>',AwsAccountId='<aws-account-id>')
while True:
    response = client.describe_ingestion(DataSetId='<dataset-id>',IngestionId='<ingetion-id>',AwsAccountId='<aws-account-id>')
        if response['Ingestion']['IngestionStatus'] in ('INITIALIZED', 'QUEUED', 'RUNNING'):
            time.sleep(10) #change sleep time according to your dataset size
        elif response['Ingestion']['IngestionStatus'] == 'COMPLETED':
            print("refresh completed. RowsIngested {0}, RowsDropped {1}, IngestionTimeInSeconds {2}, IngestionSizeInBytes {3}".format(
                response['Ingestion']['RowInfo']['RowsIngested'],
                response['Ingestion']['RowInfo']['RowsDropped'],
                response['Ingestion']['IngestionTimeInSeconds'],
                response['Ingestion']['IngestionSizeInBytes']))
            break
        else:
            print("refresh failed! - status {0}".format(response['Ingestion']['IngestionStatus']))
            sys.exit(1)

数据集的DataSetId可以从aws URI中找到,或者使用'list_data_sets'方法列出所有数据集并从字段['DataSetSummaries']['DataSetId']方法调用中获取DataSetId回应

IngestionId - 设置唯一 ID,我使用的是纪元中的当前时间 [str(int(time.time()))]

- 使用 quicksight 数据集中的计划选项计划刷新

您可以使用 quicksight-dataset

中的计划选项为 'hourly'、'daily'、'weekly' 或 'monthly' 节奏安排刷新