我正在尝试使用示例here(# The full, minimum-extra-calls case.
下的class boto.dynamodb2.table.Table...
块)创建一个带有全局二级索引的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>))
答案 0 :(得分:1)