I have some program like below
import boto3
from boto3.dynamodb.conditions import Key, Attr
import sys
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('g_data')
#var1 = sys.argv[1]
data = table.scan(
FilterExpression=Attr('customer_id').eq(1))
print(data['Items'][0]['customer_id'])
print(data['Items'][0]['tools_type']['antivirus'])
it works when hard code customer id at below line
FilterExpression=Attr('customer_id').eq(1))
But I want to pass this customer id via runtime sys.argv if i mention like this
FilterExpression=Attr('customer_id').eq(var1))
I am getting error like below:
Traceback (most recent call last):
File "C:\csv\abdynmodb\abdynamodb1.py", line 15, in <module>
print(data['Items'][0]['tools_type']['antivirus'])
IndexError: list index out of range