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
preguntada hace 3 meses118 visualizaciones
2 Respuestas
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
EXPERTO
respondido hace 3 meses
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
respondido hace 2 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas