我正在尝试使用boto3创建dynamodb表。但我得到了以下错误:
“botocore.exceptions.ClientError:调用CreateTable操作时出错(ValidationException):KeySchema无效:第一个KeySchemaElement不是哈希键类型”
更多信息: 我的帐户中没有任何全局表
我试过的代码:
import boto3
client = boto3.client('dynamodb')
response = client.create_table(
AttributeDefinitions=[
{
'AttributeName': 'student_id',
'AttributeType': 'N'
},
{
'AttributeName': 'student_name',
'AttributeType': 'S'
},
{
'AttributeName': 'course_id',
'AttributeType': 'S'
}
],
TableName='students',
KeySchema=[
{
'AttributeName': 'student_name',
'KeyType': 'HASH'
},
{
'AttributeName': 'student_id',
'KeyType': 'RANGE'
},
],
LocalSecondaryIndexes=[
{
'IndexName': 'course_id',
'KeySchema': [
{
'AttributeName': 'course_id',
'KeyType': 'RANGE'
}
],
'Projection': {
'ProjectionType': 'ALL'
}
},
],
BillingMode='PAY_PER_REQUEST',
)
还应明确指定LSI的哈希键
相关问题 更多 >
编程相关推荐