Skip to content

Commit a9fe111

Browse files
surajitsurajit
authored andcommitted
log integration with dynamodb
1 parent b3ef673 commit a9fe111

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

aws/__init__.py

Whitespace-only changes.

aws/services/__init__.py

Whitespace-only changes.

aws/services/dynamo_db/__init__.py

Whitespace-only changes.

aws/services/dynamo_db/logs.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import json
2+
3+
import boto3
4+
import botocore
5+
6+
import settings
7+
8+
dynamodb = boto3.resource('dynamodb', aws_access_key_id=settings.AWS_SECRET_KEY_ID,
9+
aws_secret_access_key=settings.AWS_SECRET_KEY,
10+
region_name=settings.AWS_REGION)
11+
12+
13+
class BotoClientException(Exception):
14+
pass
15+
16+
17+
async def create_log(data):
18+
try:
19+
table = dynamodb.Table('Log')
20+
trans = {'log_id': data['log_id'],
21+
'request_ip': data['request_ip'],
22+
'message': json.dumps(data['message'])}
23+
return table.put_item(Item=trans)
24+
except botocore.exceptions.ClientError as e:
25+
raise BotoClientException(e)
26+

0 commit comments

Comments
 (0)