I'm trying to perform update_item to my DynamoDB for each entry in a list. In the list the columns are id and total_sales where the total sales updates every hour. The idea is to parse the list and update each item (associated with the id in the list) and update the total_sales value but there are more than 5000 entries in the list and it exceeded my maximum throughput. Is there a more efficient way than simply doing this
def write_to_dynamo(id, total_sales):
response = table.update_item(
Key={
'id': id
},
UpdateExpression="set stats.revenue = :r",
ExpressionAttributeValues={
':r': total_sales
},
ReturnValues="UPDATED_NEW"
)
return response
def main():
for item in lst:
write_to_dynamo(item.id, item.total_sales)