Created
March 15, 2022 01:52
-
-
Save 2innnnn0/61a56ab45b7473b9bacba988e8ab127c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import time | |
import calendar | |
import tqdm | |
import pandas as pd | |
# 본인의 AWS_KEY | |
ACCESS_KEY = '*********' | |
SECRET_KEY = '*********' | |
AWS_ACCOUNT_ID = '*********' | |
REGION_NAME='ap-northeast-2' | |
client = boto3.client('quicksight', | |
aws_access_key_id=ACCESS_KEY, | |
aws_secret_access_key=SECRET_KEY, | |
region_name=REGION_NAME | |
) | |
# 관리하고 있는 대시보드 ID 입력 (수정하기) | |
# https://ap-northeast-2.quicksight.aws.amazon.com/sn/dashboards/<dashboard_id> | |
DASHBOARD_ID = '' | |
INGESTION_ID = str(calendar.timegm(time.gmtime())) | |
dataset_dict = client.describe_dashboard(AwsAccountId=AWS_ACCOUNT_ID, | |
DashboardId=DASHBOARD_ID) | |
dataset_list = list(pd.Series(dataset_dict['Dashboard']['Version']['DataSetArns']).apply(lambda x : x[-36:])) | |
for DATASET_ID in dataset_list: | |
start = time.time() | |
response = client.create_ingestion(DataSetId=DATASET_ID, | |
IngestionId=INGESTION_ID, | |
AwsAccountId=AWS_ACCOUNT_ID) | |
while True: | |
response = client.describe_ingestion(DataSetId=DATASET_ID, IngestionId=INGESTION_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("새로고침 완료. {0}개 행 성공, {1}개 행 건너뜀, 소요시간(초):{2}".format( | |
response['Ingestion']['RowInfo']['RowsIngested'], | |
response['Ingestion']['RowInfo']['RowsDropped'], | |
response['Ingestion']['IngestionTimeInSeconds'])) | |
break | |
else: | |
print("새로고침 실패! - status {0}".format(response['Ingestion']['IngestionStatus'])) | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment