获取使用 boto3 的 wcu/rcu 为 200 或 200+ 的表格。

huangapple go评论109阅读模式
英文:

Get tables whose wcu/rcu 200 or 200+ using boto3

问题

在使用 boto3 获取表格的 wcu/rcu 值方面,我有 200 多个表格,我需要列出 wcu/rcu 值设置为 200 或 200+ 的表格,所以我希望能够使用 boto3 找到解决方案,因为有些表格是按需的,有些已启用按预配吞吐量。我真的不想手动处理这个。

我尝试的代码如下:

  1. import boto3
  2. dynamodb = boto3.resource("dynamodb")
  3. table = dynamodb.Table("table-name")
  4. billing_mode = table.billing_mode_summary
  5. print(billing_mode)

但这没有提供期望的输出。是否有方法可以做到这一点?

英文:

Is there any way to get table wcu/rcu value using boto3,
I have 200+ tables from which I need to list out tables whose wcu/rcu values are set to 200 or 200+, so looking for solution using boto3 if i can get these tables, as some tables are on demand and some have been provisioned throughput enable.
I really don't want to do this manually,
Code I tried is:

  1. import boto3
  2. dynamodb = boto3.resource("dynamodb")
  3. table = dynamodb.Table("table-name")
  4. billing_mode = table.billing_mode_summary
  5. print(billing_mode)

but this doesn't provided desired output.
Is there any way to do this.

答案1

得分: 1

你可以使用dynamodb.describe_table来获取表的WCU(Write Capacity Units)和RCU(Read Capacity Units)值,如下所示:

  1. dynamodb = boto3.client('dynamodb')
  2. ...
  3. table_info = dynamodb.describe_table(TableName="table-name")['Table']
  4. wcu = table_info['ProvisionedThroughput']['WriteCapacityUnits']
  5. rcu = table_info['ProvisionedThroughput']['ReadCapacityUnits']
  6. ... 您的条件来验证这些值...

要获取更多详细信息,请查看DynamoDB.Client.describe_table

英文:

> Is there any way to get table wcu/rcu value using boto3

You can use dynamodb.describe_table like this:

  1. dynamodb = boto3.client('dynamodb')
  2. ...
  3. table_info = dynamodb.describe_table(TableName="table-name")['Table']
  4. wcu = table_info['ProvisionedThroughput']['WriteCapacityUnits']
  5. rcu = table_info['ProvisionedThroughput']['ReadCapacityUnits']
  6. ... Your conditions to verify the values...

For more details check DynamoDB.Client.describe_table

huangapple
  • 本文由 发表于 2023年2月23日 20:40:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/75544970.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定