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
gefragt vor 3 Monaten118 Aufrufe
2 Antworten
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
EXPERTE
beantwortet vor 3 Monaten
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
beantwortet vor 2 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen