AWS DynamoDB with Python (Boto3) — Part 5 — Bulk Insert & Delete with DynamoDB

Accessing DynamoDB with Python

If you haven’t read the previous article in this series AWS DynamoDB with Python (Boto3) — Part 4 — Update Attribute & Delete Item from DynamoDB

boto3 client offers support for DynamoDB batch operations via batch_writer() function. Below is the example for bulk insert with DynamoDB

Similarly for bulk delete, we can use the same batch_writer() function

Remember, the constrains we discussed in previous article still applies to batch operations as well

We can mix delete_item() & put_item() in a single batch call

Remember, the batch operation as a whole is not atomic in nature.

Meaning, If we try to insert 10 records & 5 insert calls got successful but the 6th one got failed, doesn’t mean the first 5 inserts will be rolled back

Thats all about Bulk Insert & Delete with DynamoDB !

GitHub Repo URL — https://github.com/iamvickyav/dynamodb-with-python-boto3

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store