Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Local DynamoDB: How to view contents of a table?

For listing all tables in a locally-installed instance of DynamoDB, I know that the command is:

aws dynamodb list-tables --endpoint-url http://localhost:8000

Now, I want to view the contents of one of the tables. What is the command to do that?

like image 305
yash Avatar asked May 19 '16 08:05

yash


People also ask

How do I view DynamoDB table locally?

To access DynamoDB running locally, use the --endpoint-url parameter. The following is an example of using the AWS CLI to list the tables in DynamoDB on your computer. The AWS CLI can't use the downloadable version of DynamoDB as a default endpoint. Therefore, you must specify --endpoint-url with each AWS CLI command.

How do I get items from DynamoDB table?

To read an item from a DynamoDB table, use the GetItem operation. You must provide the name of the table, along with the primary key of the item you want. The following AWS CLI example shows how to read an item from the ProductCatalog table. With GetItem , you must specify the entire primary key, not just part of it.

Can you create a view in DynamoDB?

With AWS Glue Elastic Views, you can specify a DynamoDB table as a source and materialize views in Amazon Elasticsearch Service, Amazon S3, and Amazon Redshift. AWS Glue Elastic Views is serverless and scales capacity up or down automatically based on demand, so there's no infrastructure to manage.

How do I edit items in DynamoDB table?

To update an existing item in an Amazon DynamoDB table, you use the UpdateItem operation. You must provide the key of the item that you want to update. You must also provide an update expression, indicating the attributes that you want to modify and the values that you want to assign to them.


1 Answers

Go to "http://localhost:8000/shell/" and execute the below script. Please change the table name as per your requirement.

When you run the local DynamoDB the above URL should be up and running.

var dynamodb = new AWS.DynamoDB({ region: 'us-east-1', endpoint: "http://localhost:8000" }); var tableName = "TESTTABLE";  var params = { TableName: tableName, Select: "ALL_ATTRIBUTES" };   function doScan(response) { if (response.error) ppJson(response.error); // an error occurred else {     ppJson(response.data); // successful response      // More data.  Keep calling scan.     if ('LastEvaluatedKey' in response.data) {         response.request.params.ExclusiveStartKey = response.data.LastEvaluatedKey;         dynamodb.scan(response.request.params)             .on('complete', doScan)             .send();     } } } console.log("Starting a Scan of the table"); dynamodb.scan(params) .on('complete', doScan) .send(); 
like image 98
notionquest Avatar answered Oct 13 '22 11:10

notionquest