【发布时间】:2017-09-08 14:17:21
【问题描述】:
尝试使用flask-dynamo在Dynamo db中创建包含三个字段的表,得到错误“”
botocore.exceptions.ClientError botocore.exceptions.ClientError:调用CreateTable操作时发生错误(ValidationException):键模式中的属性数必须与属性定义中定义的属性数匹配
这里是配置创建表发电机数据库
@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"
提前致谢
【问题讨论】:
标签: python-3.x amazon-web-services flask amazon-dynamodb