[Python] Float types are not supported. Use Decimal types instead

Discussão em 'Python' iniciado por Stack, Julho 12, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using Python 3.7 to store data in a DynamoDB database and encountering the following error message when I try and write an item to the database:

    Float types are not supported. Use Decimal types instead.


    My code:

    ddb_table = my_client.Table(table_name)

    with ddb_table.batch_writer() as batch:
    for item in items:
    item_to_put: dict = json.loads(json.dumps(item), parse_float=Decimal)

    # Send record to database.
    batch.put_item(Item=item_to_put)


    "items" is a list of Python dicts. If I print out the types of the "item_to_put" dict, they are all of type str.

    Continue reading...

Compartilhe esta Página