Skip to content

Instantly share code, notes, and snippets.

@alexwlchan
Created February 23, 2017 13:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save alexwlchan/b545a7f6e501b5503c60ee730432445b to your computer and use it in GitHub Desktop.
#!/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