【发布时间】:2019-02-09 10:13:28
【问题描述】:
我正在运行一个本地 dockerised DynamoDB:
~ docker run -d -p 8000:8000 amazon/dynamodb-local
...其中有一个表,通过 aws dynamodb CLI* 创建。
从 ipython shell boto3 可以毫无问题地找到表:
db = boto3.resource('dynamodb',
endpoint_url='http://localhost:8000',
region_name='eu-west-2')
print([t for t in db.tables.all()])
# ==> [dynamodb.Table(name=u'myTable')]
...但是当从本地运行的烧瓶应用程序中的断点访问此表时,boto3 找不到该表:
db = boto3.resource('dynamodb',
endpoint_url='http://localhost:8000',
region_name='eu-west-2')
[t for t in db.tables.all()]
# ==> []
我想不出任何关于烧瓶应用程序的上下文会改变 boto3 工作方式的事情,所以我有点卡住了。为什么对db.tables.all() 的调用在两种情况下都不返回相同的结果?
两个上下文都从同一个 virtualenv 运行,使用 boto v1.7.1 和 python 2.7.13
*用于创建表的CLI命令:
~ aws dynamodb create-table --table-name myTable --attribute-definitions AttributeName=api_key,AttributeType=S AttributeName=session_id,AttributeType=S AttributeName=time_stamp,AttributeType=N --key-schema AttributeName=session_id,KeyType=HASH --global-secondary-indexes IndexName=api_key-time_stamp-index,KeySchema=["{KeyType=HASH,AttributeName=api_key}","{KeyType=RANGE,AttributeName=time_stamp}"],Projection="{ProjectionType=ALL}",ProvisionedThroughput="{ReadCapacityUnits=5,WriteCapacityUnits=5}" --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 --endpoint-url http://localhost:8000 --region eu-west-2
【问题讨论】:
标签: python flask amazon-dynamodb