Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7859157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:47:50+00:00 2026-06-02T21:47:50+00:00

I am trying to update an atomic count counter with Python Boto 2.3.0, but

  • 0

I am trying to update an atomic count counter with Python Boto 2.3.0, but can find no documentation for the operation.

It seems there is no direct interface, so I tried to go to “raw” updates using the layer1 interface, but I was unable to complete even a simple update.

I tried the following variations but all with no luck

dynoConn.update_item(INFLUENCER_DATA_TABLE, 
                     {'HashKeyElement': "9f08b4f5-d25a-4950-a948-0381c34aed1c"}, 
                     {'new': {'Value': {'N':"1"}, 'Action': "ADD"}})    

dynoConn.update_item('influencer_data', 
                     {'HashKeyElement': "9f08b4f5-d25a-4950-a948-0381c34aed1c"}, 
                     {'new': {'S' :'hello'}})                                 

dynoConn.update_item("influencer_data", 
                     {"HashKeyElement": "9f08b4f5-d25a-4950-a948-0381c34aed1c"},
                     {"AttributesToPut" : {"new": {"S" :"hello"}}})      

They all produce the same error:

  File "/usr/local/lib/python2.6/dist-packages/boto-2.3.0-py2.6.egg/boto/dynamodb/layer1.py", line 164, in _retry_handler
    data)
boto.exception.DynamoDBResponseError: DynamoDBResponseError: 400 Bad Request
{u'Message': u'Expected null', u'__type': u'com.amazon.coral.service#SerializationException'}

I also investigated the API docs here but they were pretty spartan.

I have done a lot of searching and fiddling, and the only thing I have left is to use the PHP API and dive into the code to find where it “formats” the JSON body, but that is a bit of a pain. Please save me from that pain!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T21:47:51+00:00Added an answer on June 2, 2026 at 9:47 pm

    Sorry, I misunderstood what you were looking for. You can accomplish this via layer2 although there is a small bug that needs to be addressed. Here’s some Layer2 code:

    >>> import boto
    >>> c = boto.connect_dynamodb()
    >>> t = c.get_table('counter')
    >>> item = t.get_item('counter')
    >>> item
    {u'id': 'counter', u'n': 1}
    >>> item.add_attribute('n', 20)
    >>> item.save()
    {u'ConsumedCapacityUnits': 1.0}
    >>> item  # Here's the bug, local Item is not updated
    {u'id': 'counter', u'n': 1}
    >>> item = t.get_item('counter')  # Refetch item just to verify change occurred
    >>> item
    {u'id': 'counter', u'n': 21}
    

    This results in the same over-the-wire request as you are performing in your Layer1 code, as shown by the following debug output.

    2012-04-27 04:17:59,170 foo [DEBUG]:StringToSign:
    POST
    /
    
    host:dynamodb.us-east-1.amazonaws.com
    x-amz-date:Fri, 27 Apr 2012 11:17:59 GMT
    x-amz-security-    token:<removed> ==
    x-amz-target:DynamoDB_20111205.UpdateItem
    
    {"AttributeUpdates": {"n": {"Action": "ADD", "Value": {"N": "20"}}}, "TableName": "counter", "Key": {"HashKeyElement": {"S": "counter"}}}
    

    If you want to avoid the initial GetItem call, you could do this instead:

    >>> import boto
    >>> c = boto.connect_dynamodb()
    >>> t = c.get_table('counter')
    >>> item = t.new_item('counter')
    >>> item.add_attribute('n', 20)
    >>> item.save()
    {u'ConsumedCapacityUnits': 1.0}
    

    Which will update the item if it already exists or create it if it doesn’t yet exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to update a row in my table but the update function seems
I trying to update a model on a callback but the validation is causing
I am trying to create an update trigger in MySQL Community Server 5.5.16 but
Im trying to update some nested params from a form. I can see that
Trying to update a table on a linked server (SQL 2000/2005) but my server
I'm trying to update fields from three different tables but I'm getting some errors:
I'm trying to Update a table but I keep getting the exception : Update
I am trying to increase post's comment vote in atomic operation so I am
In trying to update my SDK to the latest, some things installed, but others*
Im trying to update a simple model in MVC,but its not working,it throws an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.