The course is part of these learning pathsSee 1 more
This course looks at how to read and write data to and from DynamoDB tables. We’ll also touch on performance considerations to allow you to get the most possible performance out of your DynamoDB deployment.
- Reading and Writing from the console
- Reading and Writing from code
- Looking for items in your DynamoDB tables
- Developers looking to learn how to read and write data to/from your DynamoDB tables
- Cloud Development
- AWS Software Development Kit (SDK)
- DynamoDB Basics
Let's take a look at a write operation into a DynamoDB table, this time from code using AWS Lambda and Python. Here we have our code in the Lambda Console and I'm populating a data structure that I'm going to use as a record to put into our table. What I'm using is the event. In this case, you know, it's a Lambda. So, it's going to get called perhaps by an S3 event, a step function, or something similar. So, let me show you, I'll go to 'Configure test'. And as you can see as the event, I'm just passing the exact same structure that we would use if we were populating this record directly in the DynamoDB Console.
Let's go back here. Our code creates a data structure and populates the event just as I mentioned. And then, we forget about that and then we switch over to our Boto3 configuration. In this case, we request a resource from Boto3, which is a DynamoDB resource. Once we have that, we ask for a table connection which we do here in line 17, we just pass the table name on the DynamoDB resource that we created will give us an open connection to that table. And finally, this is where you would put your real code here. In this case, I'm just calling the PutItem method, and I'm passing the item parameter with the value of our data structure.
So, if this was real code, this is where you would have all your operation, perhaps you would sanitize your data first and do other kinds of operations, perhaps a lot more PutItem calls other than just one. So, here's our table. As you can see, we have four items here. And let's go back, let me show you the record one more time. I'm passing the ID 89 and some fake values here. I'll go ahead and run it. As you can see there's no errors here. Let's go back to our DynamoDB console. I'm going to refresh this. As you can see, we only have four items here, I'll refresh and there's our record. I'm going to click on it and switch to JSON view. As you can see, our record is here and our code worked as expected. Of course, writing a bunch of data is completely useless unless we actually know how to later retrieve and look for items and query specific records. And I have that solution ready for you with the Lambda that scans and queries our table.
Software Development has been my craft for over 2 decades. In recent years, I was introduced to the world of "Infrastructure as Code" and Cloud Computing.
I loved it! -- it re-sparked my interest in staying on the cutting edge of technology.
Colleagues regard me as a mentor and leader in my areas of expertise and also as the person to call when production servers crash and we need the App back online quickly.
My primary skills are:
★ Software Development ( Java, PHP, Python and others )
★ Cloud Computing Design and Implementation
★ DevOps: Continuous Delivery and Integration