Batch-loading data into DynamoDB

We will first discuss how to batch-load data into DynamoDB from a comma-separated values (CSV) file called sample_data/dynamodb-sample-data.txt. Rather than insert an individual statement for each item, this is a much more efficient process, as the data file is decoupled from the Python code:

EventId,EventDay,EventCount324,20171010,2324,20171012,10324,20171013,10324,20171014,6324,20171016,6324,20171017,2300,20171011,1300,20171013,3300,20171014,30 

Add another method, called update_dynamo_event_counter(), that updates DynamoDB records using the DynamoRepository class.

Here are the contents of the serverless-microservice-data-api/aws_dynamo/dynamo_insert_items_from_file.py Python script:

from boto3 import resource ...

Get Building Serverless Microservices in Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.