Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Download and Restore DynamoDB
aws dynamodb scan --table-name TABLE > export.json
import json
import boto3
dynamo = boto3.client('dynamodb')
TABLE_NAME = 'TABLE_NAME'
JSON_PATH = '/Users/USERNAME/git/GitHub/dynamodump/export.json'
with open(JSON_PATH, 'r') as file:
data = file.read()
parsed_file = json.loads(data)
for item_to_import in parsed_file['Items']:
print(f"Inserting {item_to_import['AccountId']['S']} - {item_to_import['CheckId']['S']}")
dynamo.batch_write_item(
RequestItems={
TABLE_NAME:[{
'PutRequest': {
'Item': item_to_import
}
}]
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment