-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathtransact_get.py
43 lines (39 loc) · 1.15 KB
/
transact_get.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
from __future__ import print_function # Python 2/3 compatibility
import boto3, json, decimal
from boto3.dynamodb.conditions import Key, Attr
from botocore.exceptions import ClientError
client = boto3.client('dynamodb', region_name='us-west-2')
try:
response = client.transact_get_items(
TransactItems=[
{
'Get': {
'TableName': "RetailDatabase",
'Key': {
'PK': {
'S': '123'
},
'SK': {
'S': "abc"
},
},
},
},
{
'Get': {
'TableName': "RetailDatabase",
'Key': {
'PK': {
'S': "789"
},
'SK': {
'S': "xyz"
},
},
},
},
]
)
print(json.dumps(response))
except ClientError as e:
print(e.response['Error']['Message'])