trying to insert records from CSV file to dynamodb but not getting inserted

0

Hi , i try to insert just two records from csv file to DynamoDB the below is the python code

    with open(csv_file_path, 'r') as csvfile:
          csvreader = csv.reader(csvfile)

           header = next(csvreader)
            try:
                for row in csvreader:
                  # Construct an item for DynamoDB
                   item = {header[i]: row[i] for i in range(len(header))}
                  # Insert the item into DynamoDB
                   table.put_item(Item=item)

                  print("Data inserted into DynamoDB table.")
             except Exception as e:
                          print(f"Error: {e}")

i am not getting any exception while executing the code it successfully executed but the records are not inserted in dynamodb I dont know how to debug this code from db perspective is there any logs which helps how to fix this issue please help.

keyanke
질문됨 3달 전118회 조회
2개 답변
0

I can't see too much wrong with the code and I would absolutely expect an exception to be raised if there was something causing an error.

One thing to check is that the header[i] value for each item matches the primary key as defined in the DynamoDB table. It should be it's worth looking at.

profile pictureAWS
전문가
답변함 3달 전
0

print("Data has been inserted into the DynamoDB table.")
Is this message being displayed?

If for some reason there are 0 records retrieved from the CSV file, no error will occur, but no items will be added.

profile picture
danishi
답변함 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠