Skip to content

Instantly share code, notes, and snippets.

@jrcryer
Created September 24, 2014 14:49
Show Gist options
  • Save jrcryer/d7f2c92e8253d6c57fb1 to your computer and use it in GitHub Desktop.
Save jrcryer/d7f2c92e8253d6c57fb1 to your computer and use it in GitHub Desktop.
DynamoDB Ruby
#require 'rubygems'
require 'aws-sdk'
dynamo_db = AWS::DynamoDB.new
table = dynamo_db.tables['table-name']
table.load_schema
table.items.each do |incident|
attributes = incident.attributes.to_hash
locations = attributes['locations']
gz = Zlib::GzipReader.new(StringIO.new(locations.to_s))
json = gz.read
locations = JSON.parse(json)
locations.each do |loc|
unless loc['junctionNumber'].nil?
puts attributes['incidentId'].to_i
puts attributes['summary']
puts loc
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment