• <legend id='djpy1'><style id='djpy1'><dir id='djpy1'><q id='djpy1'></q></dir></style></legend>

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

        <bdo id='djpy1'></bdo><ul id='djpy1'></ul>
    1. <i id='djpy1'><tr id='djpy1'><dt id='djpy1'><q id='djpy1'><span id='djpy1'><b id='djpy1'><form id='djpy1'><ins id='djpy1'></ins><ul id='djpy1'></ul><sub id='djpy1'></sub></form><legend id='djpy1'></legend><bdo id='djpy1'><pre id='djpy1'><center id='djpy1'></center></pre></bdo></b><th id='djpy1'></th></span></q></dt></tr></i><div id='djpy1'><tfoot id='djpy1'></tfoot><dl id='djpy1'><fieldset id='djpy1'></fieldset></dl></div>
      <tfoot id='djpy1'></tfoot>
      1. 在 DynamoDB 中使用带有保留字的 ProjectionExpression 和 Boto3

        Using a ProjectionExpression with reserved words with Boto3 in DynamoDB(在 DynamoDB 中使用带有保留字的 ProjectionExpression 和 Boto3)
          <bdo id='U20Sy'></bdo><ul id='U20Sy'></ul>

        • <tfoot id='U20Sy'></tfoot>

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

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

                    <tbody id='U20Sy'></tbody>
                  <legend id='U20Sy'><style id='U20Sy'><dir id='U20Sy'><q id='U20Sy'></q></dir></style></legend>
                  本文介绍了在 DynamoDB 中使用带有保留字的 ProjectionExpression 和 Boto3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 boto3 从我的 DynamoDB 数据库中选择数据

                  I'm selecting data from my DynamoDB database using boto3

                  dynamodb = boto3.resource('dynamodb')
                  table = dynamodb.Table(table_name)
                  response = table.scan(ProjectionExpression='Id,Name')['Items']
                  

                  工作正常.现在我还想检索一个(不幸的是)用保留字命名的属性 - 比如说 CONNECTION.

                  Works fine. Now I also want to retrieve an attribute that is (unfortunately) named with a reserved word - let's say CONNECTION.

                  response = table.scan(ProjectionExpression='Id,Name,Connection')['Items']
                  

                  我收到类似

                  调用 Scan 时发生错误 (ValidationException)操作:无效的 ProjectionExpression:属性名称是保留的关键词;保留关键字:连接

                  An error occurred (ValidationException) when calling the Scan operation: Invalid ProjectionExpression: Attribute name is a reserved keyword; reserved keyword: Connection

                  我知道在使用过滤器或查询时有一种别名技术,但是对于来自 boto3 的简单投影是否存在这种技术?

                  I know there's an aliasing technique if using filters or queries, but does this exist for simple projections from boto3?

                  推荐答案

                  原来这和直接调用DynamoDB API一样很容易解决.

                  Turns out that this is easily solved the same as when calling the DynamoDB API directly.

                  我们应该为任何保留字使用别名,然后使用 ExpressionAttributeName 参数/属性.

                  We should use an alias for any reserved word, and then provide a mapping from the alias back to the 'true' name with the ExpressionAttributeName parameter/property.

                  response = table.scan(ProjectionExpression = 'Id, Name, #c',
                                        ExpressionAttributeNames = {'#c': 'Connection'})['Items']
                  

                  这篇关于在 DynamoDB 中使用带有保留字的 ProjectionExpression 和 Boto3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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% 就足够了)
                  • <bdo id='gyo3O'></bdo><ul id='gyo3O'></ul>
                    • <legend id='gyo3O'><style id='gyo3O'><dir id='gyo3O'><q id='gyo3O'></q></dir></style></legend>
                    • <small id='gyo3O'></small><noframes id='gyo3O'>

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

                              <tbody id='gyo3O'></tbody>
                            <tfoot id='gyo3O'></tfoot>