-
Notifications
You must be signed in to change notification settings - Fork 0
/
createTable
36 lines (31 loc) · 892 Bytes
/
createTable
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
import boto3
dynamodb = boto3.resource('dynamodb', region_name='YOUR-REGION')
tableName = "YOUR TABLE NAME"
table = dynamodb.create_table(
TableName=tableName,
KeySchema=[
{
'AttributeName': 'ATTRIBUTE 1',
'KeyType': 'HASH' # Partition key
},
{
'AttributeName': 'ATTRIBUTE 2',
'KeyType': 'RANGE' # Sort Key
}
],
AttributeDefinitions=[
{
'AttributeName': 'ATTRIBUTE 1',
'AttributeType': 'N'
},
{
'AttributeName': 'ATTRIBUTE 2',
'AttributeType': 'N'
}
],
ProvisionedThroughput={
'ReadCapacityUnits': 10, # Size provisions
'WriteCapacityUnits': 10 # Size provisions
}
)
print("Table status:", tableName, ">>>", table.table_status) # shows table status as CREATING if done correctly