对流层发电机数据库语法代码



我有下面的代码,我正在尝试创建一个动态数据库表,我已经将资源代码分配给了一个变量。我无法缩进文件中的变量部分。

如果attribute和keyschema语法的数组很好,有人能帮上忙吗?我可以更改什么来纠正这个缩进问题。

====================

> dynamodb_table=Table(
>               "DYNAMODB_JWT_IAM",
>                       AttributeDefinitions = [AttributeDefinition([
>                               {
>                                 AttributeName="deviceId",
>                               AttributeType="HASH"
>                                      },
>                                  {
>                                                       AttributeName="solutionId",
>                                                       AttributeType="S"
>                                               }
>                                            )]],
>                       KeySchema = [KeySchema(
>               {
>                       AttributeName="solutionId",
>                                   KeyType="RANGE",
>                               },
>               {
>                                   AttributeName="deviceId",
>                               KeyType="HASH",
>                           }
>                           )],
>       ProvisionedThroughput = ProvisionedThroughput(
>               ReadCapacityUnits = 5L,
>                           WriteCapacityUnits = 6L,
>                           ),
>       TableName = DYNAMODB_JWT_IAM,
>                   Tags=dynamodb.Tags(dynamodb_tags)
>                   )   self.template.add_resource(dynamodb_table)

您能更具体地说明为什么不能以编程方式更正缩进吗?

我手动整理了您的缩进,发现AttributeDefinition的右括号顺序不正确。请参阅下面我的评论:

dynamodb_table=Table(
"DYNAMODB_JWT_IAM",
AttributeDefinitions=[
AttributeDefinition([
{
AttributeName="deviceId",
AttributeType="HASH"
},
{
AttributeName="solutionId",
AttributeType="S"
}
)] # your closing bracket sequence is incorrect; switch the order of your closing parenthesis and square bracket
],
KeySchema=[
KeySchema(
{
AttributeName="solutionId",
KeyType="RANGE",
},
{
AttributeName="deviceId",
KeyType="HASH",
}
)
],
ProvisionedThroughput=ProvisionedThroughput(
ReadCapacityUnits = 5L,
WriteCapacityUnits = 6L,
),
TableName=DYNAMODB_JWT_IAM,
Tags=dynamodb.Tags(dynamodb_tags)
)
self.template.add_resource(dynamodb_table)

最新更新