调用BatchWriteItem操作时发生错误(ValidationException):提供的键元素与架构不匹配

时间:2019-03-24 09:19:15

标签: python python-2.7

我正在使用lambda函数将csv文件存储到发电机dB中,但出现此错误:

  

调用时发生错误(ValidationException)   BatchWriteItem操作:提供的键元素与   模式:ClientError

import boto3

s3=boto3.client('s3')
dynamodb=boto3.resource('dynamodb')

def csv_reader(event, context):
    #print(event)

    bucket= event['Records'][0]['s3']['bucket']['name']
    key= event['Records'][0]['s3']['object']['key']

    obj = s3.get_object(Bucket=bucket, Key=key)

    rows= obj['Body'].read().split('\n')

    table= dynamodb.Table('batchdata')

    with table.batch_writer() as batch:
        for row in rows:

           batch.put_item(Item={

            'id':row.split(',')[0],
            'courses':row.split(',')[1],
            'statusOne':row.split(',')[2],
            'statusTwo':row.split(',')[3],
            'stream':row.split(',')[4]

            })

0 个答案:

没有答案