Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Amazon DynamoDB - Part IV

Because we specified the timestamp field as the partition key, querying for reminders at a specific timestamp is efficient using a key condition:

from pprint import pprint

import boto3
from boto3.dynamodb.conditions import Key

dynamodb = boto3.resource('dynamodb')
response = dynamodb.Table('reminder').query(
  KeyConditionExpression=Key('timestamp').eq(1511647270)
)
pprint(response['Items'])
## [{u'text': u'batch write example',
##    u'timestamp': Decimal('1511647270'),
##    u'ttl': Decimal('1511733670'),
##    u'userID': u'geish@voicera.ai'},
##  {u'text': u'another user',
##    u'timestamp': Decimal('1511647270'),
##    u'ttl': Decimal('1511733670'),
##    u'userID': u'user@example.com'}]
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content