Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "aws-sdk"
- require "time"
- item_size = ARGV[0].to_i
- puts "you can set number of item to put with ARGV." unless ARGV
- dynamodb = Aws::DynamoDB::Client.new
- item_size.times {|i|
- sleep rand(1..2)
- t = Time.now
- params = {
- table_name: ARGV[1],
- return_consumed_capacity: "TOTAL",
- item: {
- userId: "0001-0000-0017-0001-0001",
- gender: t.to_i.even? ? "m" : "f",
- age: rand(0..60),
- datetime: t.to_s,
- timestamp:t.to_i
- }
- }
- begin
- result = dynamodb.put_item(params)
- puts "[#{i}]Put Item. #{result.consumed_capacity}"
- rescue Aws::DynamoDB::Errors::ServiceError => error
- puts "Unable to put item:"
- puts "#{error.message}"
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement