<legend id='4qMuo'><style id='4qMuo'><dir id='4qMuo'><q id='4qMuo'></q></dir></style></legend>

    <tfoot id='4qMuo'></tfoot>
    • <bdo id='4qMuo'></bdo><ul id='4qMuo'></ul>

      <i id='4qMuo'><tr id='4qMuo'><dt id='4qMuo'><q id='4qMuo'><span id='4qMuo'><b id='4qMuo'><form id='4qMuo'><ins id='4qMuo'></ins><ul id='4qMuo'></ul><sub id='4qMuo'></sub></form><legend id='4qMuo'></legend><bdo id='4qMuo'><pre id='4qMuo'><center id='4qMuo'></center></pre></bdo></b><th id='4qMuo'></th></span></q></dt></tr></i><div id='4qMuo'><tfoot id='4qMuo'></tfoot><dl id='4qMuo'><fieldset id='4qMuo'></fieldset></dl></div>
    1. <small id='4qMuo'></small><noframes id='4qMuo'>

    2. Python - 使用 Boto3 从 DynamoDB 检索最大主键值

      Python - Retrieving max primary key value from DynamoDB using Boto3(Python - 使用 Boto3 从 DynamoDB 检索最大主键值)

        <tfoot id='fiRrf'></tfoot>

          <tbody id='fiRrf'></tbody>

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

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

          <legend id='fiRrf'><style id='fiRrf'><dir id='fiRrf'><q id='fiRrf'></q></dir></style></legend>

              • <bdo id='fiRrf'></bdo><ul id='fiRrf'></ul>

                本文介绍了Python - 使用 Boto3 从 DynamoDB 检索最大主键值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我只是想通过使用 Boto3 的查询/扫描来检索我的主键的最大值.我正在尝试完成此操作,因此我的程序可以简单地将我设置为等于最大ID"值的变量增加 1 以用于下一个表条目.

                I'm simply trying to retrieve the max value of my primary keys with a query/scan using Boto3. I'm trying to accomplish this so my program can simply increment a variable I'll set equal to the max "ID" value by 1 for the next table entry.

                DynamoDB 表的屏幕截图

                response = table.scan(
                    FilterExpression=Attr('ID'). #Here is where I'd assume a condition
                )                                #is placed to find the highest value but
                                                 #the Boto3 doc doesn't seem to have a 
                                                 #method like 'max()' or something...
                

                四处搜索我发现如何使用原始的boto"来做到这一点,所以我确信有一种方法可以使用它的新版本boto3",但我还没有找到任何东西.

                Searching around I found how to do this using the original 'boto' so I'm sure there is a way using its newer version 'boto3' but I haven't found anything yet.

                任何帮助/指导将不胜感激!谢谢!

                Any help/guidance would be greatly appreciated! Thanks!

                Boto3 文档:http://boto3.阅读thedocs.io/en/latest/guide/dynamodb.html#querying-and-scanning

                推荐答案

                我遇到了同样的问题,找不到优雅的解决方案.但是,如果您的主键只是整数,您可以执行以下操作来查找最大键:

                I am suffering from the same issue and can't find an elegant solution. However if your primary keys are just integers you can do something like this to find the max key:

                import boto3
                
                dynamodb = boto3.resource('dynamodb')
                table = dynamodb.Table(table_name)
                max_key = table.item_count
                

                这篇关于Python - 使用 Boto3 从 DynamoDB 检索最大主键值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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% 就足够了)
                <legend id='dIzfm'><style id='dIzfm'><dir id='dIzfm'><q id='dIzfm'></q></dir></style></legend>

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

                    <bdo id='dIzfm'></bdo><ul id='dIzfm'></ul>

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