Skip to content

Instantly share code, notes, and snippets.

@jokull
Created July 31, 2012 21:38
Show Gist options
  • Save jokull/3220810 to your computer and use it in GitHub Desktop.
Save jokull/3220810 to your computer and use it in GitHub Desktop.
import boto
schema = conn.create_schema(
hash_key_name='player_id',
hash_key_proto_value='S',
range_key_name='points',
range_key_proto_value='N'
)
table = conn.create_table(
name='scoreboard',
schema=schema,
read_units=3,
write_units=5
)
# Skrifum tvö item í einu
jokull = table.new_item(hash_key='1', range_key='5', attrs={'Name':'jokull'})
johann = table.new_item(hash_key='2', range_key='3', attrs={'Name':'johann'})
puts = conn.new_batch_write_list()
puts.add_batch(table, puts=[jokull, johann])
conn.batch_write_item(puts)
# >>>
# {'Responses': {'scoreboard': {'ConsumedCapacityUnits': 2.0}},
# 'UnprocessedItems': {}}
# Mun einfaldari API í boto til að skrifa einn object í einu.
bjossi = table.new_item(hash_key='3', range_key='1', attrs={'Name':'bjossi'})
arni = table.new_item(hash_key='4', range_key='22', attrs={'Name':'arni'})
bjossi.put()
arni.put()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment