Created
February 23, 2017 13:28
-
-
Save alexwlchan/b545a7f6e501b5503c60ee730432445b to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
""" | |
A script for quickly injecting records into DynamoDB. | |
Useful for testing apps that hang off a DynamoDB event stream. | |
""" | |
import itertools | |
import sys | |
import time | |
import boto3 | |
dynamodb = boto3.resource('dynamodb') | |
if len(sys.argv) != 3: | |
sys.exit('Usage: importer <table_name> <start>') | |
TABLE_NAME = sys.argv[1] | |
START = sys.argv[2] | |
table = dynamodb.Table(TABLE_NAME) | |
for i in itertools.count(int(START)): | |
table.put_item( | |
Item={ | |
'identifier': 'record_%d' % i | |
} | |
) | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment