9/01/2021

AWS dynamoDB safe searching way, search item by scan and get it by paginator.

 refer to follow code

--

import boto3

dynamo_client = boto3.client('dynamodb')

def Search_Item(TABLE_NAME, uid):
paginator = dynamo_client.get_paginator('scan')
operation_parameters = {
'TableName': TABLE_NAME,
'FilterExpression': 'UID = :search',
'ExpressionAttributeValues': {
':search': {'S': uid},
}
}
page_iterator = paginator.paginate(**operation_parameters)
return page_iterator

UID_list = []
TABLE_NAME ='example_Table'
UID ='example_uid'

page_iterator = Search_Item(TABLE_NAME, UID)
for page in page_iterator:
for item in page['Items']:
UID_list.append(item['UID']['S'])

--


Thank you.

www.marearts.com




No comments:

Post a Comment