Skip to content

Instantly share code, notes, and snippets.

@okaram
Created October 14, 2012 04:50
Show Gist options
  • Save okaram/3887379 to your computer and use it in GitHub Desktop.
Save okaram/3887379 to your computer and use it in GitHub Desktop.
dynamodb examples
conn=boto.connect_dynamodb() # if set in ~/.boto
# or
conn = boto.connect_dynamodb(aws_access_key_id='...',aws_secret_access_key='...')
myschema=conn.create_schema(hash_key_name='username',hash_key_proto_value='S');
table=conn.create_table(name='users', schema=myschema, read_units=1, write_units=1);
it=table.get_item("okaram")
# or select only some fields
it=table.get_item("okaram", attributes_to_get=['email'])
user_data={'name':'Orlando Karam', 'password':'abc123', 'email':'[email protected]'};
user=table.new_item(hash_key='okaram', attrs=user_data);
user.put();
users=table.scan(scan_filter={'username':CONTAINS('o')})
# and later we cab iterate like
for user in users:
print user;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment