Created
May 15, 2019 13:24
-
-
Save Sam-Martin/65da0d5605f9e5359bf40af2933fb076 to your computer and use it in GitHub Desktop.
Download and Restore DynamoDB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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