我对Python还不熟悉。我在一个Lambda函数中用Python编写了一段代码,该函数更新DynamoDB表(ebsDaysToExpire)中的a值。这很管用。当我想获取新的更新值,以便稍后在脚本中作为send\u mail函数的一部分传递它时,我会陷入困境。你知道吗
我尝试过添加response = table.get_item
语句,但我就是无法实现。你知道吗
if response['Count'] == 0: #volume not being tracked in table
try:
response = table.put_item(
Item={
'volID': vid,
'ebsDaysToExpire': 7,
'snapshotStatus': 'incomplete',
'snapshotDate': 'incomplete',
'lifecycleStatus': 'start_7',
'snapshotID': 'incomplete',
'snapshotDaysToExpire': '30'
},
ConditionExpression='attribute_not_exists(volID)'
)
except ClientError as e:
print(e.response['Error']['Message'])
else:
try:
response = table.update_item(
Key={
'volID': vid
},
UpdateExpression='set ebsDaysToExpire = ebsDaysToExpire + :val',
ExpressionAttributeValues={
':val': decimal.Decimal(-1)
},
ReturnValues='UPDATED_NEW'
)
except ClientError as e:
print(e.response['Error']['Message'])
这就是我的代码现在的样子,它将从DynamoDB表中的'table'后面返回新值_放置项目'更新表(返回值)。这将被传递为“xdays”。感谢人权高专办的协助。你知道吗
相关问题 更多 >
编程相关推荐