我正在使用Python 3.7将数据存储在DynamoDB数据库中,但是在尝试向数据库写入项目时遇到了以下错误信息:
Float types are not supported. Use Decimal types instead.
我的代码:
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"是一个Python字典列表。如果我打印出"item_to_put"字典的类型,它们都是字符串类型。
提前感谢您的任何帮助。
item_to_put
究竟是什么? - Marcin