-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdynamodbcreation
More file actions
53 lines (44 loc) · 1.08 KB
/
dynamodbcreation
File metadata and controls
53 lines (44 loc) · 1.08 KB
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
47
48
49
50
51
52
#TABLE CREATION
#dynamodb table creation
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.create_table (
TableName ='WoodCafe',
KeySchema = [
{
'AttributeName': 'Special',
'KeyType': 'HASH'
},
{
'AttributeName': 'Price',
'KeyType': 'RANGE'
}
],
AttributeDefinitions = [
{
'AttributeName': 'Special',
'AttributeType': 'S'
},
{
'AttributeName':'Price',
'AttributeType': 'N'
}
],
ProvisionedThroughput={
'ReadCapacityUnits':10,
'WriteCapacityUnits':10
}
)
print(table)
#ADD ITEMS
#dynamodb add items to table
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('WoodCafe')
response = table.put_item(
Item = {
'Special': 'grilled cheese',
'Price': int('9')
}
)
print(response)