I am using boto 2.45 and Python 2.7. Here is the code:
import time
import boto
from boto.dynamodb2.layer1 import DynamoDBConnection
from boto.dynamodb2.table import Table
from boto.dynamodb2.fields import HashKey, RangeKey, KeysOnlyIndex,GlobalAllIndex
access_key = 'XXX'
secret_key = 'YYY'
conn = boto.dynamodb2.connect_to_region(
'us-east-2',
aws_access_key_id=access_key,
aws_secret_access_key=secret_key
)
table = Table('Table1', connection=conn);
table.put_item(data={
'name':'aaa.rar',
'time':int(time.time()),
'size':200000000000,
'title':'from boto'
})
Everytime I run this code, it always creates a new item in the table with name 'aaa.rar'. Table's primary key is name. This is not what I want. I want to raise an exception if an item with the same name already exists in the table.