DDB table not updating all items

27 views Asked by At

I am running the below python code from Linux terminal which would run to insert the "Time" and "Message" of 5K items in the dummy_table. First few executions inserted all the items fine, once the table reached 50K items, the next set of executions are not inserting all the expected 5K items in the table only few 100 are getting updated.

Code:

dynamodb = boto3.resource('dynamodb', region_name='us-east-2')
table_bms = dynamodb.Table('dummy_table')

def update_tables():
    try:
        eastern = dateutil.tz.gettz('US/Eastern')
        with table_bms.batch_writer() as writer:
            for i in range(5000):
                msg = f"counter {i}"                
                writer.put_item(Item={"Time": datetime.datetime.now(tz=eastern).strftime('%m/%d/%Y %H:%M:%S.%f %Z'), "Message": msg})

    except ClientError as err:
        print(
            "Couldn't load data into table %s. Here's why: %s: %s",
            err.response["Error"]["Code"],
            err.response["Error"]["Message"],
        )

Can anyone suggest if anyone had faced similar problems in the past.?

0

There are 0 answers