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, 2019 in AWS by Survi
3,986 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, 2019 by Priyaj
• 57,640 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

edited Jun 8 by MD 354 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, 2019 in AWS by Priyaj
• 57,640 points
697 views
0 votes
1 answer
0 votes
1 answer

How to load data into a table in DynamoDB using Java?

You can create a .json file with the ...READ MORE

answered Feb 25, 2019 in AWS by Priyaj
• 57,640 points
2,716 views
0 votes
1 answer
+1 vote
2 answers
0 votes
1 answer

How to create a DynamoDB table using Java SDK?

The code to create a table in ...READ MORE

answered Feb 22, 2019 in AWS by Priyaj
• 57,640 points
658 views
0 votes
1 answer

How to create a DynamoDB table in AWS?

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

answered Feb 22, 2019 in AWS by Priyaj
• 57,640 points
207 views