DynamoDB - Load Table

Loading a table typically consists of creating a source file, ensuring that the source file conforms to a DynamoDB compatible syntax, sending the source file to the destination, and then confirming that the seed was successful.
Use the GUI console, Java, or another option to complete the task.
Load table using GUI console
Download data using a combination of command line and console. You can download data in several ways, some of which are as follows:
- Console
- Command line
- code as well
- Data Pipeline (feature discussed later in the guide)
However, for speed, this example uses both the shell and the console. First, load the source data into the destination with the following syntax:
aws dynamodb batch-write-item --request-items file://[filename]
For example -
aws dynamodb batch-write-item --request-items file://MyProductData.json
Check the success of the operation by opening the console at −
https://console.aws.amazon.com/dynamodb
Select Tables in the navigation bar and select the target table from the list of tables.
Select the Elements tab to view the data you used to populate the table. Select Cancel to return to the list of tables.
Download table using Java
Use Java by first creating a source file. Our source file uses the JSON format. Each product has two primary key attributes (ID and nomenclature) and a JSON Map (Stat) −
[ { "ID" : ... , "Nomenclature" : ... , "Stat" : { ... } }, { "ID" : ... , "Nomenclature" : ... , "Stat" : { ... } }, ... ]
You can view the following example −
{ "ID" : 122 , "Nomenclature" : "Particle Blaster 5000" , "Stat" : { "Manufacturer" : "XYZ Inc." , "sales" : "1M+" , "quantity" : 500 , "img_src" : "http://www.xyz.com/manuals/particleblaster5000.jpg" , "description" : "A laser cutter used in plastic manufacturing. " } }
The next step is to place the file in the directory used by your application.
Java basically uses the putItem and path methods to perform loading.
You can view the following code example for processing a file and uploading it −