I am new to AWS and python. I have been trying to get the records from dynamoDB using boto3 in python. Could anyone please suggest how to get records when value1 not equal to value2. I am able to query with eq
but not ne
. Below is my code.
response = table.query(
KeyConditionExpression=Key('Id').eq('123') & Key('status').ne('Booked')
)
I am getting below error when I execute the above code.
Lambda execution failed with status 200 due to customer function error: 'Key' object has no attribute 'ne'.
KeyCondition don't include ne
operator for the sort key
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.KeyConditions.html
You will need to user FilterExpression instead :
FilterExpression : 'status <> :Booked', ExpressionAttributeValues : {':Booked' : 'Booked'}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With