引发语法错误的flask-dynamodb的示例? [英] Example for flask-dynamodb that is throwing an exception for Syntax error?
本文介绍了引发语法错误的flask-dynamodb的示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
查看flask_dynamo api的示例。 https://flask-dynamo.readthedocs.io/en/latest/quickstart。 html 只是好奇为什么会出错?
Looking at the example for the flask_dynamo api. https://flask-dynamo.readthedocs.io/en/latest/quickstart.html Just curious why this would give an error?
from flask import Flask
from flask_dynamo import Dynamo
app = Flask(__name__)
app.config['DYNAMO_TABLES'] = [
{
TableName='users',
KeySchema=[dict(AttributeName='username', KeyType='HASH')],
AttributeDefinitions=[dict(AttributeName='username', AttributeType='S')],
ProvisionedThroughput=dict(ReadCapacityUnits=5, WriteCapacityUnits=5)
}, {
TableName='groups',
KeySchema=[dict(AttributeName='name', KeyType='HASH')],
AttributeDefinitions=[dict(AttributeName='name', AttributeType='S')],
ProvisionedThroughput=dict(ReadCapacityUnits=5, WriteCapacityUnits=5)
}
]
错误是:TableName ='users',
^
SyntaxError:无效语法
The error is: TableName='users', ^ SyntaxError: invalid syntax
此无效语法如何?
推荐答案
也许是文档中的错字?我猜想这样做的目的是使数组中的项目作为字典。尝试这样做:
Maybe a typo in the docs? I'm guessing the intention is to have the items in the array as dictionaries. Try to do that:
app.config['DYNAMO_TABLES'] = [
dict(
TableName='users',
KeySchema=[dict(AttributeName='username', KeyType='HASH')],
AttributeDefinitions=[dict(AttributeName='username', AttributeType='S')],
ProvisionedThroughput=dict(ReadCapacityUnits=5, WriteCapacityUnits=5)
),
dict(
TableName='groups',
KeySchema=[dict(AttributeName='name', KeyType='HASH')],
AttributeDefinitions=[dict(AttributeName='name', AttributeType='S')],
ProvisionedThroughput=dict(ReadCapacityUnits=5, WriteCapacityUnits=5)
)
]
这篇关于引发语法错误的flask-dynamodb的示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文