Reputation: 305
I am using Node.js
var AWS = require('aws-sdk');
AWS.config.update({
region: "region",
endpoint: "https://dynamodb.region.amazonaws.com"
});
var dynamodb = new AWS.DynamoDB();
var params = {
TableName: "acc_new"
};
dynamodb.describeTable(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(JSON.stringify(data));
});
Output :
{ AttributeDefinitions: [ { AttributeName: 'Id', AttributeType: 'S' } ],
TableName: 'acc_new',
KeySchema: [ { AttributeName: 'Id', KeyType: 'HASH' } ],
ProvisionedThroughput: { ReadCapacityUnits: 5, WriteCapacityUnits: 5 } }
output consist of only key schemas(hash and range keys only) associated with the table, Not all the attributes. I want to fetch all attributes associated with data in the table.
Like:
{ AttributeName: 'AccountName', AttributeType: 'S' }
{ AttributeName: 'CreatedBy', AttributeType: 'S' }
...
...
Is there any way to get descriptions of a dynamoDb table with all of its data fields.
Upvotes: 7
Views: 13223
Reputation: 1171
There is no conventional way to do it, but here is how I would do it if you truly need it to be done:
The lambda function would do the following:
In a couple of days or longer (depending on the number of rows), you would have all column names from the DynamoDB table stored in the SQL DB.
Upvotes: 1
Reputation: 971
For the above mentioned case it is not possible to list all the attributes in the table. Because Dynamodb is NoSql database attributes are defined in advance, only hash key and range key are defined when creating a table.
Upvotes: 0
Reputation: 39226
DynamoDB is a NoSQL database. While creating the table, it doesn't expect all the attributes to be defined in the table. Also, each item can have any number of non-key attributes. Only key attributes are common or mandatory across all the items in the table.
For the above mentioned reasons, the describe table can't provide all the attributes present in the table.
Upvotes: 3