![]() |
Reading an item from a Dynamo table is a vital operation in application development that allows you to work on data efficiently. We will explore how we can read items from the table using different methods used for different purposes. Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability. With DynamoDB, you can create database tables that can store and retrieve any amount of data and serve any level of request traffic. You can scale up or scale down your table throughput capacity without downtime or performance degradation. AWS DynamoDB Table Structure
For example, consider table ‘People‘.It has 3 items in it. Each item has 3 attributes namely, FirstName, LastName, and Age.For a more detailed overview read this article. Prerequisites
Setting Up the DynamoDB EnvironmentThere are 3 ways you can use DynamoDB:
Implementation:Step 1: Login into AWS -> https://aws.amazon.com/ Management Step 2: After signing in you will land on the AWS Management Console page and search for Dynamo as shown below. Read an item using the Amazon Management Console (GUI)Step 1: After landing on the DynamboDB dashboard, go to tables from the sidebar and click on your table name (in my case ‘Music’). Step 2: From the top right press Explore table items. This will open the page to read items from the table using queries. Step 3: Select Query, write Partitionthe key, and Sort key to find in table. These keys are your primary keys which you set during the creation of the table. Hit Run. ![]() Query Step 4: The above output will return all the items with the Partition & Sort key that you put in. Read an item using the CloudShell or Amazon CLI (Command Line Interface)Step 1: After landing on the DynamoDB dashboard page select CloudShell from the bottom left. This will open the CLI to run queries on the table. Step 2: After Cloudshell has loaded, type the below command to read the item from the table. aws dynamodb get-item --table-name Music --key '{ "Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}}'
Step 3: Hit enter and all the items satisfying your query will be displayed. Output: ConclusionWe have successfully read an item from the DynamoDB table (Music) using two methods Amazon Management Console and CloudShell (AWS CLI). Using GUI you can easily read items by just writing queries but if you want to read an item from outside Amazon Management Console we can use AWS CLI and convert output in JSON format. Read an item from a DynamoDB table – FAQ’s1. How to fetch all items from DynamoDB table?
2. How do I get data from DynamoDB?
|
Reffered: https://www.geeksforgeeks.org
DynamoDB |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |