Search code examples
amazon-web-servicesaws-lambdaamazon-dynamodbboto3

Python boto3 AWS Dynamodb table Query & Scan methods on 'Client' object vs 'Resource' object


https://boto3.amazonaws.com/v1/documentation/api/1.9.42/reference/services/dynamodb.html#service-resource

For DynamoDB webservice we have:

dynamodb = boto3.resource('dynamodb')

and

client = boto3.client('dynamodb')

Both have Query and Scan methods. Are there any pros and cons using Query on a client object vs Resource object?


Solution

  • You can actually use both to interact with AWS API. But there are some differences. Client is a low level service access. Resource is higher level object oriented API. Most of the times, even on aws docs you'll see client is being used. Unless my requirements need something else, I stick to the official docs.

    To know more in depth you can see this and this.