title: DynamoDB: How do I do a putItem but just if key doesn't exists in Python?
body: <p>I use Amazon AWS DynamoDB just new now. In Future I want to put Items in my table but just if a Item with the same key doesn't exist so that I do not override an existing value. You know how I do that? My code:</p>
  
  <pre><code>from __future__ import print_function # Python 2/3 compatibility
  import boto3
  import json
  import decimal
  
  # Helper class to convert a DynamoDB item to JSON.
  class DecimalEncoder(json.JSONEncoder):
      def default(self, o):
          if isinstance(o, decimal.Decimal):
              if o % 1 &gt; 0:
                  return float(o)
              else:
                  return int(o)
          return super(DecimalEncoder, self).default(o)
  
  dynamodb = boto3.resource('dynamodb', region_name='eu-central-1')
  
  table = dynamodb.Table('Movies')
  
  title = "The Big New Movie"
  year = 2015
  
  response = table.put_item(
      Item={
          'year': year,
          'title': title,
          'info': {
               'plot':"Nothing happens at all.",
               'rating': decimal.Decimal(0)
          }
      },
   )
  </code></pre>
  
  <p>I heard of ConditionExpression. But I don't know how to add this on. It don't work like this:</p>
  
  <pre><code>response = table.put_item(
      Item={
          'year': year,
          'title': title,
          'info': {
               'plot':"Nothing happens at all.",
               'rating': decimal.Decimal(0)
          }
      },
       ConditionExpression = "attribute_not_exists",
   )
  </code></pre>
  
  <p>Because then I get the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/iTom/ownCloud/Documents/Workspace/PyCharm/DynamoDBTest/MoviesItemOps1.py", line 32, in &lt;module&gt;
  ConditionExpression = "attribute_not_exists",
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/boto3/resources/factory.py", line 518, in do_action
  response = action(self, *args, **kwargs)
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/boto3/resources/action.py", line 83, in __call__
  response = getattr(parent.meta.client, operation_name)(**params)
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/botocore/client.py", line 252, in _api_call
  return self._make_api_call(operation_name, kwargs)
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/botocore/client.py", line 542, in _make_api_call
  raise ClientError(parsed_response, operation_name)
  botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the PutItem operation: Invalid ConditionExpression: Syntax error; token: "&lt;EOF&gt;", near: "attribute_not_exists"
  </code></pre>