擅长:python、mysql、java
<p>注意,<code>put_item</code>的参数<code>expected</code>现在是<a href="http://%20http://boto.cloudhackers.com/en/latest/ref/dynamodb2.html#boto.dynamodb2.layer1.DynamoDBConnection.put_item" rel="nofollow noreferrer">deprecated</a>:</p>
<blockquote>
<p>Parameters: expected (map)</p>
<p>There is a newer parameter available. Use ConditionExpression instead.</p>
</blockquote>
<p>使用<code>condition_expression</code>代替:</p>
<pre class="lang-py prettyprint-override"><code>connection.put_item(
'table',
item={
'locationId': {'S': 'a1'},
'timestamp': {'S': str(time.time())}
},
condition_expression='attribute_exists(locationId)'
)
</code></pre>
<p>也可以链接表达式和使用命名参数,例如:</p>
^{pr2}$
<p><a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.SpecifyingConditions.html" rel="nofollow noreferrer">See <em>Performing Conditional Writes with Condition Expressions</em> for more details</a>。在</p>