I'm using boto3 to access AWS dynamodb table and batch write to it, here is the sample code:
with table.batch_writer() as batch:
try:
for i in range(10):
id = uuid.uuid4().hex
# A function which perform a job and finish with write to the table
# If the job fails, the function will raise an exception
write_to_table(batch, id)
except:
# Perform a rollback
print("{} failed".format(id))
Is it possible to perform a rollback to the entire batch using the BatchWriteItem? (in the except block for instance).
Thanks.
I found a solution, but I'm not sure it's a good one: