Skip to content

Instantly share code, notes, and snippets.

@dineshviswanath
Last active December 19, 2019 15:08
Show Gist options
  • Save dineshviswanath/f578ccf0eaa3cc50511e5082a83f1eda to your computer and use it in GitHub Desktop.
Save dineshviswanath/f578ccf0eaa3cc50511e5082a83f1eda to your computer and use it in GitHub Desktop.

Revisions

  1. dineshviswanath revised this gist Dec 19, 2019. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions dyanamodb.py
    Original file line number Diff line number Diff line change
    @@ -5,11 +5,11 @@ def dynamo_db_batch_write(items):
    dynamo_db = boto3.resource(
    'dynamodb',
    endpoint_url=get_aws_endpoint_url('dynamodb'),
    region_name=EOC_DYNAMO_DB_REGION,
    region_name=region,
    )

    table = dynamo_db.Table(EOC_DYNAMO_DB_NAME)
    table = dynamo_db.Table(table)
    with table.batch_writer() as batch:
    for item in items:
    batch.put_item(Item=item)
    logging.info('Batch insert done for {} records'.format(len(items)))

  2. dineshviswanath created this gist Dec 19, 2019.
    15 changes: 15 additions & 0 deletions dyanamodb.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    def dynamo_db_batch_write(items):
    """
    Write in db by batch
    """
    dynamo_db = boto3.resource(
    'dynamodb',
    endpoint_url=get_aws_endpoint_url('dynamodb'),
    region_name=EOC_DYNAMO_DB_REGION,
    )

    table = dynamo_db.Table(EOC_DYNAMO_DB_NAME)
    with table.batch_writer() as batch:
    for item in items:
    batch.put_item(Item=item)
    logging.info('Batch insert done for {} records'.format(len(items)))