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 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南