-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdynamoDB_create_table.py
46 lines (37 loc) · 1.08 KB
/
dynamoDB_create_table.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 10 20:36:03 2020
@author: hp
"""
import boto3
# Get the service resource.
import key_config as keys
dynamodb = boto3.resource('dynamodb', region_name='us-east-1',
aws_access_key_id=keys.AWS_ACCESS_KEY_ID,
aws_secret_access_key=keys.AWS_SECRET_ACCESS_KEY,
aws_session_token=keys.AWS_SESSION_TOKEN)
# dynamodb = boto3.resource('dynamodb')
# Create the DynamoDB table.
table = dynamodb.create_table(
TableName='userdata',
KeySchema=[
{
'AttributeName': 'email',
'KeyType': 'HASH'
}
],
AttributeDefinitions=[
{
'AttributeName': 'email',
'AttributeType': 'S'
}
],
ProvisionedThroughput={
'ReadCapacityUnits': 5,
'WriteCapacityUnits': 5
}
)
# Wait until the table exists.
table.meta.client.get_waiter('table_exists').wait(TableName='userdata')
# Print out some data about the table.
print(table.item_count)