I want to retrieve single item from DynamoDB but I'm unable to do that. I think I am missing something. I am able to scan the table using scan() function of boto but the fetching of a single item is not working. So it would be great if someone can tell me the correct way to do this.
models.py file:
import os
import boto
from boto import dynamodb2
from boto.dynamodb2.table import Table
from boto.dynamodb2.fields import HashKey, RangeKey, KeysOnlyIndex, GlobalAllIndex
AWS_ACCESS_KEY_ID = '****************'
AWS_SECRET_ACCESS_KEY = '***************************'
REGION = 'us-east-1'
TABLE_NAME = 'Users'
conn = dynamodb2.connect_to_region(REGION, aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY)
table = Table(
TABLE_NAME,
connection=conn
)
results = table.scan()
for dynamo_item in results:
print dict(dynamo_item.items())
I've tried using following:
results = table.scan(scan_filter={'email':'new'})
but got this error
boto.dynamodb2.exceptions.UnknownFilterTypeError: Operator 'scan_filter' from 'scan_filter' is not recognized.
results = table.query_2(email = 'new')
boto.dynamodb2.exceptions.UnknownFilterTypeError: Operator 'email' from 'email' is not recognized.
results = table.get_item(email='new')
boto.dynamodb2.exceptions.ValidationException: ValidationException: 400 Bad Request {u'message': u'The provided key element does not match the schema', u'__type': u'com.amazon.coral.validate#ValidationException'}