尝试使用Boto v2.25.0创建具有全局索引的DynamoDB表时出现AttributeError [英] Getting AttributeError when trying to create DynamoDB table with global index using boto v2.25.0
本文介绍了尝试使用Boto v2.25.0创建具有全局索引的DynamoDB表时出现AttributeError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试按照示例 此处 (#完整的,最低限度拨打电话的情况。
在<$ c $下c> class boto.dynamodb2.table.Table ... )。我正在使用 boto
版本2.25.0。确切的代码是:
I am trying to create a DynamoDB table with a global secondary index following the example here (The # The full, minimum-extra-calls case.
block under class boto.dynamodb2.table.Table...
). I am using boto
version 2.25.0. The exact code is:
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:模块对象没有属性表
我在做什么错了?
======
编辑:基于Jharrod的以下回答,这是代码的最终版本:
Based on Jharrod's answer below, here's the final version of the code:
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>))
推荐答案
尝试以这种方式导入它:
Trying importing it this way:
from boto.dynamodb2.table import Table
我编写了一个库,可以像好吧,在botocore之上: PynamoDB 。
I've written a library that can do this as well, on top of botocore: PynamoDB.
这篇关于尝试使用Boto v2.25.0创建具有全局索引的DynamoDB表时出现AttributeError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文