Get DynamoDB Table info using Python Boto3

This post explains how to use Python Boto3 APIs to obtain data such as Dynamodb table arn, table status, creation time, billing mode, and other details.

Prerequisite Tasks

You need to have a DynamoDB table in order to follow this lesson; see this page for instructions on how to create a DynamoDB table.

DynamoDB Table Arn using Python

To obtain the arn of a dynamodb table, see the python code example below. Replace "sample-movie-table-resource" with the name of your table.

   
import boto3

dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")

table_arn = table.table_arn
print(table_arn)
    
   

DynamoDB Table Status using Python

See the Python code sample below to find out how to get a dynamodb table's status. The name of your table should be substituted for "sample-movie-table-resource".

   
import boto3

dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")

table_status = table.table_status
print(table_status)
    
   

DynamoDB Table KeySchema using Python

To check the KeySchema of the table, see the Python code example below.

   
import boto3

dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")

key_schema = table.key_schema
print(key_schema)
    
   

DynamoDB Table attributes using Python

Check the table's attribute definitions using the sample code below.

   
import boto3

dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")

attributes = table.attribute_definitions
print(attributes)   
    
   

DynamoDB Table total Item count using Python

See the Python code sample below to get total count of items of dynamodb table.

   
import boto3

dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")

total_items = table.item_count
print(total_items) 
       
 

DynamoDB Table read/write capacity mode using Python

Refer below sample code to check the details for the read/write capacity mode.

   
import boto3

dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")

billing_mode = table.billing_mode_summary
print(billing_mode)
 

DynamoDB Table creation time using Boto3

To check the time of table creation, use the sample code below.

   
import boto3

dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")

creation_time = table.creation_date_time
print(creation_time)
    
   

Check DynamoDB Table encryption using Python

To get table's server side encryption details, use the sample code below.

   
import boto3

dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")

sse_status = table.sse_description
print(sse_status)   
    
   

Get DynamoDB Table Id using Python

To get unique identifier for the table, use the sample code below.

   
import boto3

dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")

id = table.table_id
print(id)
    
    
   

Category: Python