Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python dynamodb ExpressionAttributeValues contains invalid key: Syntax error; key:

Trying to do an update_item which is supposed to create new attributes if it doesn't find existing ones (according to documentation) but I am getting a Sytax error.

I have been wracking my brain all day trying to figure out why I am getting this and I can't seem to get past this. Thank you for any help

Error I am getting:

ClientError: An error occurred (ValidationException) when calling the UpdateItem operation:
   ExpressionAttributeValues contains invalid key: Syntax error; key: "var4"

MyCode:

dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('contacts')
    table.update_item(
    Key={'email': emailID},
    UpdateExpression=SET last_name = :var0, address_1_state = :var1, email_2 = :var2, phone = :var3, phone_2 = :var4

    ExpressionAttributeValues={
     'var0': 'Metzger', 
     'var1': 'CA', 
     'var2': 'none', 
     'var3': '949 302-9072', 
     'var4': '818-222-2311'
    }
    )
like image 544
OneAdamTwelve Avatar asked Jan 04 '20 01:01

OneAdamTwelve


1 Answers

just change the section like the following -

 ExpressionAttributeValues={
     ':var0': 'Metzger', 
     ':var1': 'CA', 
     ':var2': 'none', 
     ':var3': '949 302-9072', 
     ':var4': '818-222-2311'
    }

Hope the code will work then :)

like image 154
darkprinx Avatar answered Oct 20 '22 01:10

darkprinx