xin buxu1
xin buxu1

Reputation: 407

dynamo db: RuntimeError: table schema not loaded

table = db.tables['test_example']
table.items.each do |item|
  puts item.hash_value
end

I want to print out hash_value of all items in dynamo db table. But it shows: RuntimeError: table schema not loaded. how could i resolve it?

Upvotes: 0

Views: 298

Answers (2)

Jingtian Zhang
Jingtian Zhang

Reputation: 11

This is because you have not specified your table schema.

table.hash_key = [:id, :string]

Upvotes: 1

Jeffrey Nieh
Jeffrey Nieh

Reputation: 346

It looks to me like you're using the AWS Ruby SDK version 1 - I'd recommend upgrading to version 2 (http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#scan-instance_method) and using the scan operation to retrieve items in your DDB table.

If you want to keep using version 1, you'll need to specify the table hash (and range) key (see here: http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/DynamoDB/TableCollection.html).

Upvotes: 0

Related Questions