Skip to content

Instantly share code, notes, and snippets.

@igilham igilham/
Last active Aug 28, 2018

What would you like to do?
Copy all data (by scanning) from one DynamoDB table to another
from __future__ import print_function
import argparse
import boto3
def copy_table(source, target):
dynamodb = boto3.resource("dynamodb")
source_table = dynamodb.Table(source)
target_table = dynamodb.Table(target)
records = source_table.scan()
with target_table.batch_writer() as batch:
for item in records["Items"]:
print('copying record {}', item)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("source", help="Source table name")
parser.add_argument("target", help="target table name")
args = parser.parse_args()
print('copying items from {} to {}', args.source,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.