-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdynamodb.py
50 lines (40 loc) · 1.22 KB
/
dynamodb.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
47
48
49
50
from __future__ import print_function
import ssl
import boto3
dynamodb = boto3.resource('dynamodb', region_name = 'XXXXXX', endpoint_url = "https://dynamodb.XXXXXXXXX")
table = dynamodb.Table("Sample")
id1 = "TextImage"
id2 = "SceneImage"
def call_aws1(message):
response = table.update_item(Key = {"id" : id1}, UpdateExpression='SET command = :val1', ExpressionAttributeValues={
':val1': message }, ReturnValues="UPDATED_NEW")
print("Success")
return 1
def call_aws2(message):
response = table.update_item(Key={"id": id2}, UpdateExpression='SET command = :val1', ExpressionAttributeValues={
':val1': message}, ReturnValues="UPDATED_NEW")
print("Success")
return 1
#Main function
def main(id):
ssl._create_default_https_context = ssl._create_unverified_context
#Open the output.txt file in the read mode"
if id == id1 :
fo = open("google_ocr.txt", "rt")
try:
e = call_aws1(str(fo.read()))
except Exception as e:
print (e)
# Close opend file
fo.close()
else :
fo = open("output.txt", "rt")
try:
e = call_aws2(str(fo.read()))
except Exception as e:
print(e)
# Close opend file
fo.close()
if __name__ == "__main__":
id = input()
main(id)