Complete the code to query items by partition key in DynamoDB.
response = table.query(KeyConditionExpression=Key('[1]').eq('123'))
The partition key attribute name must be used in the KeyConditionExpression to query items correctly.
Complete the code to query items with a specific partition key value using boto3.
response = table.query(KeyConditionExpression=Key('UserId').eq([1]))
The partition key value must be a string enclosed in quotes when passed to the eq() method.
Fix the error in the query code to correctly use the partition key.
response = table.query(KeyConditionExpression=Key('[1]').eq('abc'))
The partition key attribute name must be used exactly as defined in the table schema, here 'UserId'.
Fill both blanks to query items by partition key and sort key condition.
response = table.query(KeyConditionExpression=Key('[1]').eq('user1') & Key('[2]').begins_with('2023'))
The partition key is 'UserId' and the sort key is 'SortKey'. The query filters items where UserId equals 'user1' and SortKey begins with '2023'.
Fill all three blanks to query items by partition key and filter results by an attribute.
response = table.query(KeyConditionExpression=Key('[1]').eq('user42'), FilterExpression=Attr('[2]').[3]('active'))
The partition key is 'UserId'. The filter expression checks if the 'Status' attribute equals 'active'.