[AWS DA] DynamoDB CLI

Using --project-expression:

aws dynamodb scan --table-name users --projection-expression "user_id,game_id"
复制代码
{
    "Items": [
        {
            "user_id": {
                "S": "ersaessew"
            },
            "game_id": {
                "N": "123"
            }
        },
        {
            "user_id": {
                "S": "fgxfbgf"
            },
            "game_id": {
                "N": "234"
            }
        }
    ],
    "Count": 2,
    "ScannedCount": 2,
    "ConsumedCapacity": null
}
复制代码

 

Using --filter-expression:

aws dynamodb scan --table-name users --filter-expression "user_id= :u" --expression-attribute-values '{ ":u": {"S": "ersaessew"}}'

result:

复制代码
{
    "Items": [
        {
            "user_id": {
                "S": "ersaessew"
            },
            "game_id": {
                "N": "123"
            },
            "game_ts": {
                "S": "2021-05-31T11:34:19.266Z"
            }
        }
    ],
    "Count": 1,
    "ScannedCount": 2,
    "ConsumedCapacity": null
}
复制代码

 

Using --page-size: 

total we have 2 items, set page size = 1, it performance 2 api calls.

aws dynamodb scan --table-name users --page-size 1

Result:

复制代码
{
    "Items": [
        {
            "user_id": {
                "S": "ersaessew"
            },
            "game_id": {
                "N": "123"
            },
            "game_ts": {
                "S": "2021-05-31T11:34:19.266Z"
            }
        },
        {
            "user_id": {
                "S": "fgxfbgf"
            },
            "game_id": {
                "N": "234"
            },
            "game_ts": {
                "S": "2021-05-30T11:34:19.266Z"
            }
        }
    ],
    "Count": 2,
    "ScannedCount": 2,
    "ConsumedCapacity": null
}
复制代码

 

If we want to limit api calls when using page size, we can use: --max-items:

--page-size and --max-items doesn't need to be used at the same time.

--max-items is for limit RCU

--page-size is avoid timeout

aws dynamodb scan --table-name users --page-size 1 --max-items 1
复制代码
{
    "Items": [
        {
            "user_id": {
                "S": "ersaessew"
            },
            "game_id": {
                "N": "123"
            },
            "game_ts": {
                "S": "2021-05-31T11:34:19.266Z"
            }
        }
    ],
    "Count": 1,
    "ScannedCount": 1,
    "ConsumedCapacity": null,
    "NextToken": "eyJFeGNsdXNpdmVTdGFydEtleSI6IHsidXNlcl9pZCI6IHsiUyI6ICJlcnNhZXNzZXcifSwgImdhbWVfdHMiOiB7IlMiOiAiMjAyMS0wNS0zMVQxMTozNDoxOS4yNjZaIn19fQ=="
}
复制代码

"NextToekn" is what you should use to get next batch of items.

 

aws dynamodb scan --table-name users --page-size 1 --max-items 1 --starting-token eyJFeGNsdXNpdmVTdGFydEtleSI6IHsidXNlcl9pZCI6IHsiUyI6ICJlcnNhZXNzZXcifSwgImdhbWVfdHMiOiB7IlMiOiAiMjAyMS0wNS0zMVQxMTozNDoxOS4yNjZaIn19fQ==
复制代码
{
    "Items": [
        {
            "user_id": {
                "S": "fgxfbgf"
            },
            "game_id": {
                "N": "234"
            },
            "game_ts": {
                "S": "2021-05-30T11:34:19.266Z"
            }
        }
    ],
    "Count": 0,
    "ScannedCount": 0,
    "ConsumedCapacity": null,
    "NextToken": "eyJFeGNsdXNpdmVTdGFydEtleSI6IHsidXNlcl9pZCI6IHsiUyI6ICJmZ3hmYmdmIn0sICJnYW1lX3RzIjogeyJTIjogIjIwMjEtMDUtMzBUMTE6MzQ6MTkuMjY2WiJ9fX0="
}
复制代码

If there is no items anymore:

{
    "Items": [],
    "Count": 0,
    "ScannedCount": 0,
    "ConsumedCapacity": null
}

 

posted @   Zhentiw  阅读(116)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2019-05-31 [Javascript] Customize Behavior when Accessing Properties with Proxy Handlers
2019-05-31 [Algorithm] Max Chars Problem
2019-05-31 [Functional Programming] Reader with Async ADT
2017-05-31 [PostgreSQL] Use Foreign Keys to Ensure Data Integrity in Postgres
2017-05-31 [PostgreSQL] Ensure Uniqueness in Postgres
2017-05-31 [RxJS] Hot Observable, by .share()
2016-05-31 [RxJS] Transformation operator: repeat
点击右上角即可分享
微信分享提示