flask Dynamo CreateTable操作问题(botocore.exceptions.ClientError)

时间:2017-09-08 14:17:21

标签: python-3.x amazon-web-services flask amazon-dynamodb

尝试使用flask-dynamo got error“”

在Dynamo db中创建包含三个字段的表
  

botocore.exceptions.ClientError   botocore.exceptions.ClientError:调用CreateTable操作时发生错误(ValidationException):密钥模式中的属性数必须与属性定义中定义的属性数相匹配

这里是配置create table dynamo db

@app.route('/create_table')
def create_table():
    app.config['DYNAMO_TABLES'] = [
    {
        'TableName': "user_detail",
        'KeySchema': [
            {'AttributeName': "timestamp", 'KeyType': "HASH"},
            {'AttributeName': "question", 'KeyType': "RANGE"},
        ],
        'AttributeDefinitions': [
            {'AttributeName': "timestamp", 'AttributeType': "S"},
            {'AttributeName': "question", 'AttributeType': "N"},
            {'AttributeName': "user", 'AttributeType': "N"},
        ],
        'ProvisionedThroughput': {
            'ReadCapacityUnits': 40,
            'WriteCapacityUnits': 40
        }
    }]
     dynamo = Dynamo(app)
     with app.app_context():
          dynamo.create_all()
     return "Table created"

提前致谢

1 个答案:

答案 0 :(得分:2)

您需要删除以下行:

Actions action = new Actions(driver);

action.MoveToElement(driver.FindElement(By.XPath("//div[@id='new_lookupid']/div[1]"))).
ClickAndHold().Release().Click().Perform();

IWebElement typeIntoLookup= driver.FindElement(By.XPath("//input[@id='new_lookupid_ledit']"));

   //send keys        
       typeIntoLookup.SendKeys("ElementofLookup"); //the lookup text

使用DynamoDB(与大多数NoSQL数据库一样),您不需要提前指定每个记录属性字段。您只需要提前指定哈希和范围字段。