I am using the following function to store a list of records in a dynamodb table
async def save_item_to_dynamodb(offer: List[Offer]):
try:
session = aioboto3.Session()
async with session.resource(
'dynamodb',
region_name=os.getenv('REGION'),
aws_access_key_id=os.getenv('ACCESS_KEY'),
aws_secret_access_key=os.getenv('SECRET_ACCESS_KEY')
) as dynamodb:
table = await dynamodb.Table('OGI_Offer')
for item in offer:
try:
item_dict = jsonable_encoder(item)
response = await table.put_item(Item=item_dict)
print(response)
if response['ResponseMetadata']['HTTPStatusCode'] == 200:
print(f"Registro insertado correctamente: {item.id}")
else:
print(f"Error al insertar el registro: {item.id}")
print(response)
except aioboto3.exceptions.Boto3Error as e:
print(f"Error de Boto3: {e}")
except Exception as e:
print(f"Error inesperado: {e}")
In theory it works, if I send 14 records it will return a status of 200 without any type of error for the 14 records, but when I consult the table it sometimes inserts 10 or inserts 12 but not all of the records