Bhavik Joshi
Bhavik Joshi

Reputation: 2677

how to create a dynamodb table in python boto

I am following the below document to create table boto dynamodb documentation

message_table_schema = conn.create_schema(
        hash_key_name='forum_name',
        hash_key_proto_value=str,
        range_key_name='subject',
        range_key_proto_value=str
    )

table = conn.create_table(
        name='messages',
        schema=message_table_schema,
        read_units=10,
        write_units=10
    )

I am trying the following code but some how the dynamodb object is not able to find the create_schema table.

AttributeError: 'DynamoDBConnection' object has no attribute 'create_schema'

Please let me know if this method is deprecated or if there any other way to create a table.

Upvotes: 1

Views: 1180

Answers (1)

franklinsijo
franklinsijo

Reputation: 18270

The DynamoDBConnection created using boto.dynamodb2 does not have create_schema method. It is part of boto.dynamodb.layer2.Layer2 API.

Create the connection using,

import boto.dynamodb
conn = boto.dynamodb.connect_to_region(region)

Or to create a table with boto.dynamodb2, use this create_table method or Table instead.

Upvotes: 1

Related Questions