Created
June 1, 2021 05:49
-
-
Save dineshsonachalam/6ed7674b3a0d30069d79b7e15e68afd8 to your computer and use it in GitHub Desktop.
increase_existing_attribute_value.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from LucidDynamodb.Operations import DynamoDb | |
import os | |
import logging | |
import uuid | |
from boto3.dynamodb.conditions import Key | |
logging.basicConfig(level=logging.INFO) | |
AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID") | |
AWS_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY") | |
if __name__ == "__main__": | |
db = DynamoDb(region_name="us-east-1", | |
aws_access_key_id=AWS_ACCESS_KEY_ID, | |
aws_secret_access_key=AWS_SECRET_ACCESS_KEY) | |
increase_attribute_status = db.increase_attribute_value( | |
TableName='dev_jobs', | |
Key={ | |
"company_name": "Google", | |
"role_id": "e85f79a7-0857-4086-afbd-da13ec76b442" | |
}, | |
AttributeName="yearly_hike_percent", | |
IncrementValue=5 | |
) | |
if(increase_attribute_status==True): | |
logging.info("Attribute value increment completed") | |
else: | |
logging.warning("Attribute value increment failed") | |
item = db.read_item( | |
TableName='dev_jobs', | |
Key={ | |
"company_name": "Google", | |
"role_id": "e85f79a7-0857-4086-afbd-da13ec76b442" | |
}) | |
if(item != None): | |
logging.info("Item: {}".format(item)) | |
else: | |
logging.warning("Item doesn't exist") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment