• <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

        时间:2023-07-05
          <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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:通过python的dynamodb行数,boto查询 下一篇:如何使用 boto 遍历 DynamoDB 表中的所有项目?

                  相关文章

                  • <bdo id='gyo3O'></bdo><ul id='gyo3O'></ul>
                1. <legend id='gyo3O'><style id='gyo3O'><dir id='gyo3O'><q id='gyo3O'></q></dir></style></legend>
                2. <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>

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