Insert a value into a DynamoDB table with integer attributes using BotoInvalidInput error when trying to Create or Upsert a Route53 A recordboto3 Route53 complains Could not connect to the endpoint URL:Creation of encryption keys with new policy with AWS Cli/Pythonunit testing for unverified user trying to loginResource not found error when updating a attribute in dynamoDBAWS Cognito Authentication USER_PASSWORD_AUTH flow not enabled for this clientwhy do I get a ValidationError when using put_metric_alarm in AWS boto3?exchangelib - ImportError: cannot import name 'Credentialsec2 ubuntu name or service unknown error when running jupyter notebookBoto3 AWS KMS encrypt and decrypt file

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

What is the difference between "behavior" and "behaviour"?

Detecting if an element is found inside a container

Gears on left are inverse to gears on right?

How to be diplomatic in refusing to write code that breaches the privacy of our users

Opposite of a diet

Anatomically Correct Strange Women In Ponds Distributing Swords

How did Arya survive the stabbing?

Short story about space worker geeks who zone out by 'listening' to radiation from stars

How to write papers efficiently when English isn't my first language?

Is the destination of a commercial flight important for the pilot?

What is paid subscription needed for in Mortal Kombat 11?

How can we prove that any integral in the set of non-elementary integrals cannot be expressed in the form of elementary functions?

Is there a problem with hiding "forgot password" until it's needed?

How can I get through very long and very dry, but also very useful technical documents when learning a new tool?

Where does the Z80 processor start executing from?

How to check is there any negative term in a large list?

Pole-zeros of a real-valued causal FIR system

Term for the "extreme-extension" version of a straw man fallacy?

Is `x >> pure y` equivalent to `liftM (const y) x`

Unreliable Magic - Is it worth it?

Crossing the line between justified force and brutality

How do I go from 300 unfinished/half written blog posts, to published posts?

Failed to fetch jessie backports repository



Insert a value into a DynamoDB table with integer attributes using Boto


InvalidInput error when trying to Create or Upsert a Route53 A recordboto3 Route53 complains Could not connect to the endpoint URL:Creation of encryption keys with new policy with AWS Cli/Pythonunit testing for unverified user trying to loginResource not found error when updating a attribute in dynamoDBAWS Cognito Authentication USER_PASSWORD_AUTH flow not enabled for this clientwhy do I get a ValidationError when using put_metric_alarm in AWS boto3?exchangelib - ImportError: cannot import name 'Credentialsec2 ubuntu name or service unknown error when running jupyter notebookBoto3 AWS KMS encrypt and decrypt file













0















I am using a DynamoDB table named DMS in which I regularely update some values. Therefor I first save all values from an element in a variable called "response". The element has the Primary key 220 in my example. After this I save the value of the Attribute (in my case the element with the heading 522) in the variable CounterOnePlus and add 1. After this I try to update the given Attribute of the element in the column 522. Here is my Code:






import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('DMS')
AverageValue=220
DeltaValue=522
response = table.get_item(
Key=
'Average': '%d' % AverageValue,

)
item = response['Item']
CounterOnePlus=int(item['%d' % DeltaValue])+1
print(CounterOnePlus)
table.update_item(
Key=
'Average': '%d' % AverageValue,
,
UpdateExpression='SET 522 = :val1',
ExpressionAttributeValues=
':val1': CounterOnePlus

)





The Problem I am facing is, that I am not able to save the values. The reason for this is the Name of the heading, wich is 522. Whenever I insert the value to a column with a string Header like "hallo", the value gets updated. Changing the value 522 to a string with the str(522) does not Change anything. My error message is the following:






2
Traceback (most recent call last):
File "TestBoto3.py", line 20, in <module>
':val1': CounterOnePlus
File "/home/ubuntu/.local/lib/python3.6/site-packages/boto3/resources/factory.py", line 520, in do_action
response = action(self, *args, **kwargs)
File "/home/ubuntu/.local/lib/python3.6/site-packages/boto3/resources/action.py", line 83, in __call__
response = getattr(parent.meta.client, operation_name)(**params)
File "/home/ubuntu/.local/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/ubuntu/.local/lib/python3.6/site-packages/botocore/client.py", line 661, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the UpdateItem operation: Invalid UpdateExpression: Syntax error; token: "522", near: "SET 522 ="





Any ideas on my issue? Thanks










share|improve this question


























    0















    I am using a DynamoDB table named DMS in which I regularely update some values. Therefor I first save all values from an element in a variable called "response". The element has the Primary key 220 in my example. After this I save the value of the Attribute (in my case the element with the heading 522) in the variable CounterOnePlus and add 1. After this I try to update the given Attribute of the element in the column 522. Here is my Code:






    import boto3
    dynamodb = boto3.resource('dynamodb')
    table = dynamodb.Table('DMS')
    AverageValue=220
    DeltaValue=522
    response = table.get_item(
    Key=
    'Average': '%d' % AverageValue,

    )
    item = response['Item']
    CounterOnePlus=int(item['%d' % DeltaValue])+1
    print(CounterOnePlus)
    table.update_item(
    Key=
    'Average': '%d' % AverageValue,
    ,
    UpdateExpression='SET 522 = :val1',
    ExpressionAttributeValues=
    ':val1': CounterOnePlus

    )





    The Problem I am facing is, that I am not able to save the values. The reason for this is the Name of the heading, wich is 522. Whenever I insert the value to a column with a string Header like "hallo", the value gets updated. Changing the value 522 to a string with the str(522) does not Change anything. My error message is the following:






    2
    Traceback (most recent call last):
    File "TestBoto3.py", line 20, in <module>
    ':val1': CounterOnePlus
    File "/home/ubuntu/.local/lib/python3.6/site-packages/boto3/resources/factory.py", line 520, in do_action
    response = action(self, *args, **kwargs)
    File "/home/ubuntu/.local/lib/python3.6/site-packages/boto3/resources/action.py", line 83, in __call__
    response = getattr(parent.meta.client, operation_name)(**params)
    File "/home/ubuntu/.local/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
    File "/home/ubuntu/.local/lib/python3.6/site-packages/botocore/client.py", line 661, in _make_api_call
    raise error_class(parsed_response, operation_name)
    botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the UpdateItem operation: Invalid UpdateExpression: Syntax error; token: "522", near: "SET 522 ="





    Any ideas on my issue? Thanks










    share|improve this question
























      0












      0








      0








      I am using a DynamoDB table named DMS in which I regularely update some values. Therefor I first save all values from an element in a variable called "response". The element has the Primary key 220 in my example. After this I save the value of the Attribute (in my case the element with the heading 522) in the variable CounterOnePlus and add 1. After this I try to update the given Attribute of the element in the column 522. Here is my Code:






      import boto3
      dynamodb = boto3.resource('dynamodb')
      table = dynamodb.Table('DMS')
      AverageValue=220
      DeltaValue=522
      response = table.get_item(
      Key=
      'Average': '%d' % AverageValue,

      )
      item = response['Item']
      CounterOnePlus=int(item['%d' % DeltaValue])+1
      print(CounterOnePlus)
      table.update_item(
      Key=
      'Average': '%d' % AverageValue,
      ,
      UpdateExpression='SET 522 = :val1',
      ExpressionAttributeValues=
      ':val1': CounterOnePlus

      )





      The Problem I am facing is, that I am not able to save the values. The reason for this is the Name of the heading, wich is 522. Whenever I insert the value to a column with a string Header like "hallo", the value gets updated. Changing the value 522 to a string with the str(522) does not Change anything. My error message is the following:






      2
      Traceback (most recent call last):
      File "TestBoto3.py", line 20, in <module>
      ':val1': CounterOnePlus
      File "/home/ubuntu/.local/lib/python3.6/site-packages/boto3/resources/factory.py", line 520, in do_action
      response = action(self, *args, **kwargs)
      File "/home/ubuntu/.local/lib/python3.6/site-packages/boto3/resources/action.py", line 83, in __call__
      response = getattr(parent.meta.client, operation_name)(**params)
      File "/home/ubuntu/.local/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
      return self._make_api_call(operation_name, kwargs)
      File "/home/ubuntu/.local/lib/python3.6/site-packages/botocore/client.py", line 661, in _make_api_call
      raise error_class(parsed_response, operation_name)
      botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the UpdateItem operation: Invalid UpdateExpression: Syntax error; token: "522", near: "SET 522 ="





      Any ideas on my issue? Thanks










      share|improve this question














      I am using a DynamoDB table named DMS in which I regularely update some values. Therefor I first save all values from an element in a variable called "response". The element has the Primary key 220 in my example. After this I save the value of the Attribute (in my case the element with the heading 522) in the variable CounterOnePlus and add 1. After this I try to update the given Attribute of the element in the column 522. Here is my Code:






      import boto3
      dynamodb = boto3.resource('dynamodb')
      table = dynamodb.Table('DMS')
      AverageValue=220
      DeltaValue=522
      response = table.get_item(
      Key=
      'Average': '%d' % AverageValue,

      )
      item = response['Item']
      CounterOnePlus=int(item['%d' % DeltaValue])+1
      print(CounterOnePlus)
      table.update_item(
      Key=
      'Average': '%d' % AverageValue,
      ,
      UpdateExpression='SET 522 = :val1',
      ExpressionAttributeValues=
      ':val1': CounterOnePlus

      )





      The Problem I am facing is, that I am not able to save the values. The reason for this is the Name of the heading, wich is 522. Whenever I insert the value to a column with a string Header like "hallo", the value gets updated. Changing the value 522 to a string with the str(522) does not Change anything. My error message is the following:






      2
      Traceback (most recent call last):
      File "TestBoto3.py", line 20, in <module>
      ':val1': CounterOnePlus
      File "/home/ubuntu/.local/lib/python3.6/site-packages/boto3/resources/factory.py", line 520, in do_action
      response = action(self, *args, **kwargs)
      File "/home/ubuntu/.local/lib/python3.6/site-packages/boto3/resources/action.py", line 83, in __call__
      response = getattr(parent.meta.client, operation_name)(**params)
      File "/home/ubuntu/.local/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
      return self._make_api_call(operation_name, kwargs)
      File "/home/ubuntu/.local/lib/python3.6/site-packages/botocore/client.py", line 661, in _make_api_call
      raise error_class(parsed_response, operation_name)
      botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the UpdateItem operation: Invalid UpdateExpression: Syntax error; token: "522", near: "SET 522 ="





      Any ideas on my issue? Thanks






      import boto3
      dynamodb = boto3.resource('dynamodb')
      table = dynamodb.Table('DMS')
      AverageValue=220
      DeltaValue=522
      response = table.get_item(
      Key=
      'Average': '%d' % AverageValue,

      )
      item = response['Item']
      CounterOnePlus=int(item['%d' % DeltaValue])+1
      print(CounterOnePlus)
      table.update_item(
      Key=
      'Average': '%d' % AverageValue,
      ,
      UpdateExpression='SET 522 = :val1',
      ExpressionAttributeValues=
      ':val1': CounterOnePlus

      )





      import boto3
      dynamodb = boto3.resource('dynamodb')
      table = dynamodb.Table('DMS')
      AverageValue=220
      DeltaValue=522
      response = table.get_item(
      Key=
      'Average': '%d' % AverageValue,

      )
      item = response['Item']
      CounterOnePlus=int(item['%d' % DeltaValue])+1
      print(CounterOnePlus)
      table.update_item(
      Key=
      'Average': '%d' % AverageValue,
      ,
      UpdateExpression='SET 522 = :val1',
      ExpressionAttributeValues=
      ':val1': CounterOnePlus

      )





      2
      Traceback (most recent call last):
      File "TestBoto3.py", line 20, in <module>
      ':val1': CounterOnePlus
      File "/home/ubuntu/.local/lib/python3.6/site-packages/boto3/resources/factory.py", line 520, in do_action
      response = action(self, *args, **kwargs)
      File "/home/ubuntu/.local/lib/python3.6/site-packages/boto3/resources/action.py", line 83, in __call__
      response = getattr(parent.meta.client, operation_name)(**params)
      File "/home/ubuntu/.local/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
      return self._make_api_call(operation_name, kwargs)
      File "/home/ubuntu/.local/lib/python3.6/site-packages/botocore/client.py", line 661, in _make_api_call
      raise error_class(parsed_response, operation_name)
      botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the UpdateItem operation: Invalid UpdateExpression: Syntax error; token: "522", near: "SET 522 ="





      2
      Traceback (most recent call last):
      File "TestBoto3.py", line 20, in <module>
      ':val1': CounterOnePlus
      File "/home/ubuntu/.local/lib/python3.6/site-packages/boto3/resources/factory.py", line 520, in do_action
      response = action(self, *args, **kwargs)
      File "/home/ubuntu/.local/lib/python3.6/site-packages/boto3/resources/action.py", line 83, in __call__
      response = getattr(parent.meta.client, operation_name)(**params)
      File "/home/ubuntu/.local/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
      return self._make_api_call(operation_name, kwargs)
      File "/home/ubuntu/.local/lib/python3.6/site-packages/botocore/client.py", line 661, in _make_api_call
      raise error_class(parsed_response, operation_name)
      botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the UpdateItem operation: Invalid UpdateExpression: Syntax error; token: "522", near: "SET 522 ="






      python-3.x amazon-dynamodb boto3 dynamodb-queries






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 12:56









      Nik LasNik Las

      122




      122






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Use ExpresssionAttributeNames (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html):



          table.update_item(
          Key=
          'Average': '%d' % AverageValue,
          ,
          UpdateExpression='SET #DeltaValue = :val1',
          ExpressionAttributeValues=
          ':val1': CounterOnePlus
          ,
          ExpressionAttributeNames=
          "#DeltaValue": str(DeltaValue) # 522

          )





          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55044337%2finsert-a-value-into-a-dynamodb-table-with-integer-attributes-using-boto%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Use ExpresssionAttributeNames (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html):



            table.update_item(
            Key=
            'Average': '%d' % AverageValue,
            ,
            UpdateExpression='SET #DeltaValue = :val1',
            ExpressionAttributeValues=
            ':val1': CounterOnePlus
            ,
            ExpressionAttributeNames=
            "#DeltaValue": str(DeltaValue) # 522

            )





            share|improve this answer



























              0














              Use ExpresssionAttributeNames (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html):



              table.update_item(
              Key=
              'Average': '%d' % AverageValue,
              ,
              UpdateExpression='SET #DeltaValue = :val1',
              ExpressionAttributeValues=
              ':val1': CounterOnePlus
              ,
              ExpressionAttributeNames=
              "#DeltaValue": str(DeltaValue) # 522

              )





              share|improve this answer

























                0












                0








                0







                Use ExpresssionAttributeNames (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html):



                table.update_item(
                Key=
                'Average': '%d' % AverageValue,
                ,
                UpdateExpression='SET #DeltaValue = :val1',
                ExpressionAttributeValues=
                ':val1': CounterOnePlus
                ,
                ExpressionAttributeNames=
                "#DeltaValue": str(DeltaValue) # 522

                )





                share|improve this answer













                Use ExpresssionAttributeNames (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html):



                table.update_item(
                Key=
                'Average': '%d' % AverageValue,
                ,
                UpdateExpression='SET #DeltaValue = :val1',
                ExpressionAttributeValues=
                ':val1': CounterOnePlus
                ,
                ExpressionAttributeNames=
                "#DeltaValue": str(DeltaValue) # 522

                )






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 8 at 8:14









                ydrallydrall

                1059




                1059





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55044337%2finsert-a-value-into-a-dynamodb-table-with-integer-attributes-using-boto%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                    Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                    Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved