<legend id='TBr6F'><style id='TBr6F'><dir id='TBr6F'><q id='TBr6F'></q></dir></style></legend>
  • <i id='TBr6F'><tr id='TBr6F'><dt id='TBr6F'><q id='TBr6F'><span id='TBr6F'><b id='TBr6F'><form id='TBr6F'><ins id='TBr6F'></ins><ul id='TBr6F'></ul><sub id='TBr6F'></sub></form><legend id='TBr6F'></legend><bdo id='TBr6F'><pre id='TBr6F'><center id='TBr6F'></center></pre></bdo></b><th id='TBr6F'></th></span></q></dt></tr></i><div id='TBr6F'><tfoot id='TBr6F'></tfoot><dl id='TBr6F'><fieldset id='TBr6F'></fieldset></dl></div>

  • <small id='TBr6F'></small><noframes id='TBr6F'>

      1. <tfoot id='TBr6F'></tfoot>
          <bdo id='TBr6F'></bdo><ul id='TBr6F'></ul>

      2. 如何使用 boto3 手动从 DynamoDB 有线协议转换为本机 Python 对象?

        How to convert from DynamoDB wire protocol to native Python object manually with boto3?(如何使用 boto3 手动从 DynamoDB 有线协议转换为本机 Python 对象?)

        • <bdo id='hXbmW'></bdo><ul id='hXbmW'></ul>
          <legend id='hXbmW'><style id='hXbmW'><dir id='hXbmW'><q id='hXbmW'></q></dir></style></legend>

          <small id='hXbmW'></small><noframes id='hXbmW'>

                <i id='hXbmW'><tr id='hXbmW'><dt id='hXbmW'><q id='hXbmW'><span id='hXbmW'><b id='hXbmW'><form id='hXbmW'><ins id='hXbmW'></ins><ul id='hXbmW'></ul><sub id='hXbmW'></sub></form><legend id='hXbmW'></legend><bdo id='hXbmW'><pre id='hXbmW'><center id='hXbmW'></center></pre></bdo></b><th id='hXbmW'></th></span></q></dt></tr></i><div id='hXbmW'><tfoot id='hXbmW'></tfoot><dl id='hXbmW'><fieldset id='hXbmW'></fieldset></dl></div>
                    <tbody id='hXbmW'></tbody>

                  <tfoot id='hXbmW'></tfoot>

                  本文介绍了如何使用 boto3 手动从 DynamoDB 有线协议转换为本机 Python 对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个由 DynamoDB 流触发的 Lambda.Lambda 进行一些处理,然后在 SNS 中创建有关主题的通知.理想情况下,我希望将整个新文档包含在发送到 SNS 的通知中,这样下游客户端就不必点击 DynamoDB 来获取数据.

                  I have a Lambda that is being triggered by a DynamoDB stream. The Lambda does some processing and then creates a notification on a topic in SNS. Ideally I would like to include the entire new document in the notification that goes out to SNS so that downstream clients don't have to hit DynamoDB to get the data.

                  我遇到的问题是来自 DynamoDB 流的数据采用 DynamoDB 有线格式(映射包括数据类型作为键).当我向下游客户端发送通知时,我不希望他们必须了解 DynamoDB 有线格式来解析消息(例如,如果我切换到新的底层数据存储,我将不得不重新创建该格式).

                  The problem I'm running into is that the data coming from the DynamoDB stream is in DynamoDB wire format (the maps include the data type as a key). When I send out the notification to downstream clients I don't want them to have to understand DynamoDB wire format to parse the message (for example if I switch to a new underlying data store I would then have to recreate that format).

                  显然 boto3 客户端能够将此格式解析为 Python 对象,有没有办法让我自己访问解析器?据我所知,它是作为从 DynamoDB 获取数据的一部分被调用的,但我找不到自己调用它的方法.

                  Obviously the boto3 client is capable of parsing this format into a Python object, is there a way for me to access the parser on my own? As far as I can tell it gets called as part of fetching data from DynamoDB but I can't find a way to call it on my own.

                  推荐答案

                  我也有类似的情况,我用了如下这样的方法:

                  I have a similar situation and I used the following an approach like this:

                  from boto3.dynamodb.types import TypeDeserializer
                  
                  deser = TypeDeserializer()
                  
                  ...
                  <in handler>
                      for record in event['Records']:
                          old = record['dynamodb'].get('OldImage')
                          new = record['dynamodb'].get('NewImage')
                          if old:
                              d = {}
                              for key in old:
                                  d[key] = deser.deserialize(old[key])
                  

                  这种方法对我有用.结果字典 d 包含转换后的对象,而不是传递给处理程序的有线格式版本.

                  This approach works for me. The resulting dictionary d contains the converted object rather than the wire-format version passed to the handler.

                  这篇关于如何使用 boto3 手动从 DynamoDB 有线协议转换为本机 Python 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  env: python: No such file or directory(env: python: 没有这样的文件或目录)
                  How to evaluate environment variables into a string in Python?(如何在 Python 中将环境变量评估为字符串?)
                  Python - temporarily modify the current process#39;s environment(Python - 临时修改当前进程的环境)
                  Change current process environment#39;s LD_LIBRARY_PATH(更改当前进程环境的 LD_LIBRARY_PATH)
                  Reading and writing environment variables in Python?(在 Python 中读写环境变量?)
                  When to use sys.path.append and when modifying %PYTHONPATH% is enough(何时使用 sys.path.append 以及何时修改 %PYTHONPATH% 就足够了)

                    <tfoot id='aBhU3'></tfoot>
                      <i id='aBhU3'><tr id='aBhU3'><dt id='aBhU3'><q id='aBhU3'><span id='aBhU3'><b id='aBhU3'><form id='aBhU3'><ins id='aBhU3'></ins><ul id='aBhU3'></ul><sub id='aBhU3'></sub></form><legend id='aBhU3'></legend><bdo id='aBhU3'><pre id='aBhU3'><center id='aBhU3'></center></pre></bdo></b><th id='aBhU3'></th></span></q></dt></tr></i><div id='aBhU3'><tfoot id='aBhU3'></tfoot><dl id='aBhU3'><fieldset id='aBhU3'></fieldset></dl></div>

                      <small id='aBhU3'></small><noframes id='aBhU3'>

                    • <legend id='aBhU3'><style id='aBhU3'><dir id='aBhU3'><q id='aBhU3'></q></dir></style></legend>
                      • <bdo id='aBhU3'></bdo><ul id='aBhU3'></ul>

                            <tbody id='aBhU3'></tbody>