Skip to content

Instantly share code, notes, and snippets.

@dineshsonachalam
Created June 1, 2021 05:47
Show Gist options
  • Save dineshsonachalam/6244e9d3bf5a45ab075c58162258805c to your computer and use it in GitHub Desktop.
Save dineshsonachalam/6244e9d3bf5a45ab075c58162258805c to your computer and use it in GitHub Desktop.
create_new_item.py
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)
item_creation_status = db.create_item(
TableName="dev_jobs",
Item={
"company_name": "Google",
"role_id": str(uuid.uuid4()),
"role": "Software Engineer 1",
"salary": "$1,50,531",
"locations": ["Mountain View, California", "Austin, Texas", "Chicago, IL"],
"yearly_hike_percent": 8,
"benefits": set(["Internet, Medical, Edu reimbursements",
"Health insurance",
"Travel reimbursements"
]),
"overall_review":{
"overall_rating" : "4/5",
"compensation_and_benefits": "3.9/5"
}
}
)
if(item_creation_status == True):
logging.info("Item created successfully")
else:
logging.warning("Item creation failed")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment