我正在用Chalice框架编写一个项目。我需要与DynamoDB交互,所以我想使用库来简化代码。我试图使用pynamodb,但我不知道我遗漏了什么。在
from chalice import Chalice
from chalicelib import AgentSkill
app = Chalice(app_name='helloworld2')
# this works
@app.route('/')
def index():
return {'hello': 'world'}
# this throws error
@app.route('/skill')
def addSkill():
f not AgentSkill.exists():
AgentSkill.create_table(read_capacity_units=1,
write_capacity_units=1, wait=True)
agsk = AgentSkill()
agsk.agentID = 1
agsk.save()
return {'success': 'true'}
from pynamodb.models import Model
from pynamodb.attributes import (UnicodeAttribute, NumberAttribute)
class AgentSkill(Model):
class Meta:
table_name = 'agent_skill'
region = 'us-west-2'
agentID = NumberAttribute(hash_key=True)
pynamodb
是我缺少了什么,还是需要在要求.文本文件?在
没有pynamodb在要求.txt文件我会得到一个内部服务器错误的每一个调用。加上它,我现在至少可以让hello world做出回应。/技能然后给出:
{
"Code": "InternalServerError",
"Message": "An internal server error occurred."
}
我不知道从这里到哪里去?在
目前没有回答
相关问题 更多 >
编程相关推荐