【发布时间】:2021-02-07 03:50:48
【问题描述】:
我正在尝试增加特定列的值。 我正在使用 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'
)
这是错误堆栈跟踪: 错误:
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
【问题讨论】:
-
您需要在更新查询字符串的开头添加 SET,如
update_query= "SET #clicks.#OS.#os ..." -
@neilharia7 没错,请将其添加为答案而不是评论,这样我就可以投票了:-)
-
当然,@Maurice 会添加它。
-
是的,我后来想通了.. 1 小时后 XD。无论如何,谢谢。
标签: python amazon-web-services amazon-dynamodb boto3 botocore