How to create a DynamoDB table using Python?

0 votes
Can someone help me with the method of creating a DynamoDB table in Python?
Feb 22 in AWS by Survi
479 views

1 answer to this question.

0 votes

The code that you can use to create a tabke in Dynamo DB is as follows:-

import boto3

dynamodb = boto3.resource('dynamodb', region_name='us-east-1')

table = dynamodb.create_table(
    TableName='PhoneBook',
    KeySchema=[
        {
            'AttributeName': 'ID',
            'KeyType': 'HASH'  #Partition key
        },
        {
            'AttributeName': 'Name',
            'KeyType': 'RANGE'  #Sort key
        }
    ],
    AttributeDefinitions=[
        {
            'AttributeName': 'ID',
            'AttributeType': 'N'
        },
        {
            'AttributeName': 'Name',
            'AttributeType': 'S'
        },

    ],
    ProvisionedThroughput={
        'ReadCapacityUnits': 10,
        'WriteCapacityUnits': 10
    }
)

print("Table status:", table.table_status)
OUTPUT:
Table status: CREATING

answered Feb 22 by Priyaj
• 56,200 points

Related Questions In AWS

+4 votes
1 answer

How to create a lambda fucntion using Python?

Hey @Jino, I will tell you the ...READ MORE

answered Dec 20, 2018 in AWS by Nabarupa
182 views
0 votes
1 answer

How to create a DynamoDB using AWS CLI?

You can create a DynamoDB table using ...READ MORE

answered Feb 22 in AWS by Priyaj
• 56,200 points
51 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
+1 vote
2 answers
0 votes
1 answer
0 votes
1 answer

How to create a DynamoDB table in AWS?

Creating a DynamoDB table is made very ...READ MORE

answered Feb 22 in AWS by Priyaj
• 56,200 points
68 views