Error: Float types are not supported. Use decimal types instead.

What's Causing This Error

This error occurs with the AWS Python SDK when trying to persist an item containing an attribute with a floating-point number. For example, you may encounter this error in Python if you try to save an item with a float (30.51) value.

Solution - Here's How To Resolve It

You can convert the floating-point attribute to a string using Python's str() function.

dynamodb = boto3.resource('dynamodb')  
table = dynamodb.Table('my-custom-table')

// using str will help avoid the floating point error.
item = {'name': 'item_name', 'floating_attribute': str(our_value)}

Login to the AWS Console less. Use Dynobase.

Try 7-day free trial. No credit card needed.

Product Features

© 2022 Dynobase

Using DynamoDB Console frequently?
Try Dynobase to accelerate your DynamoDB workflow. Start your 7-day free trial today.