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
105 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,100 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
136 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,100 points
22 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,100 points
50 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.