【发布时间】:2014-03-11 07:15:54
【问题描述】:
我正在尝试按照示例 here(class boto.dynamodb2.table.Table... 下的 # The full, minimum-extra-calls case. 块)创建具有全局二级索引的 DynamoDB 表。我正在使用boto 2.25.0 版。确切的代码是:
import boto
from boto import dynamodb2
table = boto.dynamodb2.table.Table('myTable',
schema=[HashKey('firstKey')],
throughput={'read':5,'write':2},
global_indexes=[GlobalAllIndex('secondKeyIndex',parts=[HashKey('secondKey')],throughput={'read':5,'write':3})],
connection=dynamodb2.connect_to_region('us-east-1',aws_access_key_id=<MYID>,aws_secret_access_key=<MYKEY>))
我收到AttributeError: 'module' object has no attribute 'table'
我做错了什么?
======
编辑:根据下面 Jharrod 的回答,这是代码的最终版本:
import os
import boto
from boto.dynamodb2.table import Table, HashKey, GlobalAllIndex
table = Table.create('myTable',
schema=[HashKey('firstKey')],
throughput={'read':5,'write':2},
global_indexes=[GlobalAllIndex('secondKeyIndex',parts=[HashKey('secondKey')],throughput={'read':5,'write':3})],
connection=boto.dynamodb2.connect_to_region('us-east-1',aws_access_key_id=<MYID>,aws_secret_access_key=<MYKEY>))
【问题讨论】:
标签: python amazon-dynamodb boto