I want to scan a small DynamoDB table using Boto3, and optionally allow the caller of this code to indicate when optional conditions should apply to this scan.
It would be convenient in code to do this:
scan_kwargs = {'Select': 'ALL_ATTRIBUTES'}
filter_exp = '' # WHAT DO HERE?
if condition1:
filter_exp &= Attr('attribute').is_in(['blah', 'bloop'])
if condition2:
filter_exp &= Attr('deleted').is_eq(True)
scan_kwargs.update({'FilterExpression': filter_exp})
response = table.scan(**scan_kwargs)
I'm trying to figure out if there is something I can set FilterExpression to be by default (indicated above in comment), for the scan to work when there are no filters to be applied.
As far as I can tell, this is impossible.