Trying importing it this way:
from boto.dynamodb2.table import Table
I've written a library that can do this as well, on top of botocore: PynamoDB.
Question
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>))
I am getting AttributeError: 'module' object has no attribute 'table'
What am I doing wrong?
======
EDIT: 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>))
Solution
Trying importing it this way:
from boto.dynamodb2.table import Table
I've written a library that can do this as well, on top of botocore: PynamoDB.