gpt4 book ai didi

python - 如何在 python boto 中创建 dynamodb 表

转载 作者:太空宇宙 更新时间:2023-11-03 15:21:38 25 4
gpt4 key购买 nike

我按照以下文档创建表 boto dynamodb documentation

message_table_schema = conn.create_schema(
hash_key_name='forum_name',
hash_key_proto_value=str,
range_key_name='subject',
range_key_proto_value=str
)

table = conn.create_table(
name='messages',
schema=message_table_schema,
read_units=10,
write_units=10
)

我正在尝试以下代码,但有些 dynamodb 对象无法找到 create_schema 表。

AttributeError:“DynamoDBConnection”对象没有属性“create_schema”

如果此方法已被弃用或者是否有其他方法来创建表,请告诉我。

最佳答案

使用 boto.dynamodb2 创建的 DynamoDBConnection 没有 create_schema 方法。它是 boto.dynamodb.layer2.Layer2 API 的一部分。

使用创建连接,

import boto.dynamodb
conn = boto.dynamodb.connect_to_region(region)

或者要使用 boto.dynamodb2 创建表,请使用此 create_table 方法或 Table 相反。

关于python - 如何在 python boto 中创建 dynamodb 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43488183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com