QueryTable.py 665 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env python
  2. import boto3
  3. import json
  4. TABLE_NAME='elaborate_employee_table'
  5. INDEX_NAME='access_application_index'
  6. client = boto3.client('dynamodb')
  7. response = client.query(
  8. TableName = TABLE_NAME,
  9. IndexName = INDEX_NAME,
  10. KeyConditionExpression='#la = :lav and begins_with(#n, :nv)',
  11. FilterExpression = '#i < :iv',
  12. ExpressionAttributeValues = {
  13. ':lav': {'N':'20190712'},
  14. ':iv': {'N':'150'},
  15. ':nv': {'S':'B'}
  16. },
  17. ExpressionAttributeNames = {
  18. '#la': 'last_accessed',
  19. '#n': 'name',
  20. '#i': 'id'
  21. },
  22. ProjectionExpression = '#n'
  23. )
  24. print(json.dumps(response['Items'], indent=4))