Hi I have a couple queries I want to run on Dynamo DB, since the query FilterExpression depends on some condition I want to set it as a variable like this:
if valid_attr:
filter_expression = Attr('keyName').is_in(valid_attr)
else:
filter_expression = None
But it seems that boto3 doesn't like None values, is there some other way to do something similar? I don't want duplicated code in my script. I can't find what are the default parameters from documentation.
I did as following
query_parameters = {attr1: value1, attr2: value2}
if valid_attr:
query_parameters.update({'FilterExpression': Attr('keyName').is_in(valid_attr)})
table.query(**query_parameters)
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