Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AWS SDK for RubyでDynamoDBを操作してみた

AWS SDK for RubyでDynamoDBを操作してみた

JAWS-UG沖縄 CMS祭り 前夜祭LT資料です。

Naoto Enokawa

October 18, 2014
Tweet

More Decks by Naoto Enokawa

Other Decks in Programming

Transcript

  1. create_table.rb resp = dynamo_db.create_table( table_name: 'tweets', key_schema: [ { attribute_name:

    'tweet_id', key_type: 'HASH', }, ], attribute_definitions: [ { attribute_name: 'tweet_id', attribute_type: 'N', }, ], provisioned_throughput: { read_capacity_units: 1, write_capacity_units: 1, }, )
  2. put_item.rb client = TweetStream::Client.new ! client.track("#macfriends") do |status| if !status.text.index("RT")

    puts "@" + status.user.screen_name + " : " + status.text resp = dynamo_db.put_item( table_name: 'tweets', item: { 'tweet_id' => status.id, 'user_id' => status.user.id, 'screen_name' => status.user.screen_name, 'tweet_text' => status.text, } ) end end