I am trying to increment values of specific columns. I am using Boto3.
update_query = '#clicks.#OS.#os = #clicks.#OS.#os + :inc, #clicks.#Brands.#brand = #clicks.#Brands.#brand + :inc, #clicks.#RAMs.#ram = #clicks.#RAMs.#ram + :inc'
table_urls.update_item(
Key={
'urlid': urlid
},
UpdateExpression=update_query,
ExpressionAttributeValues={
':inc' : Decimal(1)
},
ExpressionAttributeNames={
"#os" : os,
"#brand": brand,
"#ram" : ram,
"#clicks": "clicks",
"#OS" : "OS",
"#Brands": "Brands",
"#RAMs" : "RAMs"
},
ReturnValues='NONE'
)
Here is Error StackTrace: Error:
An error occurred (ValidationException) when calling the UpdateItem operation: Invalid UpdateExpression: Syntax error; token: "#clicks", near: "#clicks."
QUERY::>> #clicks.#OS.#os = #clicks.#OS.#os + :inc, #clicks.#Brands.#brand = #clicks.#Brands.#brand + :inc, #clicks.#RAMs.#ram = #clicks.#RAMs.#ram + :inc
Try adding SET
at the start of the update_query string. Everything rest seems proper.
update_query = 'SET #clicks.#OS.#os = #clicks.#OS.#os + :inc, #clicks.#Brands.#brand = #clicks.#Brands.#brand + :inc, #clicks.#RAMs.#ram = #clicks.#RAMs.#ram + :inc'
table_urls.update_item(
Key={
'urlid': urlid
},
UpdateExpression=update_query,
ExpressionAttributeValues={
':inc' : Decimal(1)
},
ExpressionAttributeNames={
"#os" : os,
"#brand": brand,
"#ram" : ram,
"#clicks": "clicks",
"#OS" : "OS",
"#Brands": "Brands",
"#RAMs" : "RAMs"
},
ReturnValues='NONE'
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.