-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_table.py
37 lines (35 loc) · 1.04 KB
/
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
import boto3
def create_devices_table(dynamodb = None):
dynamodb = boto3.resource('dynamodb', endpoint_url = "http://localhost:8000")
print(list(dynamodb.tables.all()))
table = dynamodb.create_table(
TableName = 'IotDevice',
KeySchema = [
{
'AttributeName': 'device_id',
'KeyType': 'HASH'
},
{
'AttributeName': 'datacount',
'KeyType': 'RANGE'
}
],
AttributeDefinitions = [
{
'AttributeName':'device_id',
'AttributeType':'S'
},
{
'AttributeName':'datacount',
'AttributeType':'N'
},
],
ProvisionedThroughput = {
'ReadCapacityUnits':10,
'WriteCapacityUnits':10
}
)
return table
if __name__ == '__main__':
device_table = create_devices_table()
print('Status:', device_table.table_status)