I am trying to do table scan on dynamodb Below is the code which is in javascript
var params = {
TableName: 'Contacts',
FilterExpression: 'begins_with(CustomerName,:value)OR begins_with(CustomerName,:val) ',
ExpressionAttributeValues: {
':value': {'S':'S'},
':val':{'S':'E'},
},
Select: 'ALL_ATTRIBUTES',
};
dynamodb.scan(params, function(err, data) {
if (err) ppJson(err); // an error occurred
else ppJson(data); // successful response
});
But I couldn't try the same using botot3.
Below is what I could achieve so far
response = table.scan(
Select= 'ALL_ATTRIBUTES',
FilterExpression=Attr('CustomerName').begins_with("S")
)
I couldn't understand how to add the OR condition. If I add, it shows error
Yes, like all the other database management systems, DynamoDB also supports all the conditional operators, User can specify a condition that is satisfied for a put, update, or delete operation to work on an item.
A filter expression determines which items within the Query results should be returned to you. All of the other results are discarded. A filter expression is applied after a Query finishes, but before the results are returned.
Conditional put The PutItem operation overwrites an item with the same key (if it exists). If you want to avoid this, use a condition expression. This allows the write to proceed only if the item in question does not already have the same key.
For AND '&' is used and for OR '|' is used
response = table.scan(
Select= 'ALL_ATTRIBUTES',
FilterExpression=Attr('CustomerName').begins_with("S") | Attr('CustomerName').begins_with("S")
)
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