Support of DynamoDB for Python

CAST supports DynamoDB via its com.castsoftware.python extension. Details about how this support is provided is discussed below.

Objects

Icon Description

Python DynamoDB Database

Python DynamoDB Table

Python Unknown DynamoDB Table

Boto3 framework

The support for DynamoDB in boto3 is focused on creating DynamoDB tables and adding links representing CRUD-like operations on them.

Methods for creation of tables

Supported API methods

Link Type Caller Callee Remark

botocore.client.DynamoDB.create_table()

N/A N/A

N/A


Side effect: creation of DynamoDB tables and parent database

boto3.resources.factory.dynamodb.ServiceResource.create_table()

N/A N/A

N/A


Side effect: creation of DynamoDB tables and parent database

Methods for getting a paginator from a DynamoDB client object

Supported API methods Link Type Caller Callee Remark
botocore.client.DynamoDB.get_paginator() N/A N/A N/A Returns a Paginator object (see below for supported Paginator methods)

High-level DynamoDB resource methods

Supported API methods 
(boto3.resources.factory.dynamodb) 

Link Type Caller Callee
batch_get_item() useSelectLink Python callable artifact Python (Unknown) DynamoDB Table
batch_write_item() useInsertLink, useDeleteLink Python callable artifact Python (Unknown) DynamoDB Table

High-level table resource methods for the DynamoDB database API

Supported API methods 
(boto3.resources.factory.dynamodb.Table) 

Link Type Caller Callee Remark
batch_writer() N/A N/A N/A Returns a BatchWriter object (see below table for supported BatchWriter methods)
delete() useDeleteLink Python callable artifact







Python (Unknown) DynamoDB Table







-
delete_item() useDeleteLink - - -
get_item() useSelectLink - - -
load() useUpdateLink - - -
put_item() useInsertLink, useDeleteLink, useSelectLink - - -
query() useSelectLink - - -
reload() useUpdateLink - - -
scan() useSelectLink - - -
update_item() useUpdateLink, useInsertLink, useSelectLink - - -

Batch-writer methods

Supported API methods (boto3.resources.factory.dynamodb.table.BatchWriter) Link Type Caller Callee
put_item() useInsertLink, useDeleteLink, useSelectLink Python callable artifact Python (Unknown) DynamoDB Table
delete_item() useDeleteLink - -

Paginator methods

Supported API methods  Link Type Caller Callee
botocore.client.DynamoDB.Paginator.Query.paginate useSelectLink Python callable artifact Python (Unknown) DynamoDB Table
botocore.client.DynamoDB.Paginator.Scan.paginate useSelectLink - -

Low-level client methods for the DynamoDB database API

API methods Link Type Caller Callee
batch_get_item() useSelectLink Python callable artifact Python (Unknown) DynamoDB Table
batch_write_item() useInsertLink, useDeleteLink Python callable artifact Python (Unknown) DynamoDB Table
delete_item() useDeleteLink Python callable artifact Python (Unknown) DynamoDB Table
delete_table() useDeleteLink Python callable artifact Python (Unknown) DynamoDB Table
get_item() useSelectLink Python callable artifact Python (Unknown) DynamoDB Table
put_item() useInsertLink, useDeleteLink, useSelectLink Python callable artifact Python (Unknown) DynamoDB Table
query() useSelectLink Python callable artifact Python (Unknown) DynamoDB Table
scan() useSelectLink Python callable artifact Python (Unknown) DynamoDB Table
transact_get_items() useSelectLink Python callable artifact Python (Unknown) DynamoDB Table
transact_write_items() useInsertLink, useDeleteLink Python callable artifact Python (Unknown) DynamoDB Table
update_item() useUpdateLink, useInsertLink, useSelectLink Python callable artifact Python (Unknown) DynamoDB Table

What results can you expect?

Creation of DynamoDB tables

The two similar create_table() methods provided by boto3 are supported: for the low-level client object and the resource object (as in the example below):

# https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.Python.01.html

import boto3

def create_movie_table(dynamodb=None):
    if not dynamodb:
        dynamodb = boto3.resource('dynamodb', endpoint_url="http://localhost:8000")

    table = dynamodb.create_table(
        TableName='Movies',
        KeySchema=[...],
        AttributeDefinitions=[...],
    )
    return table

Upon resolution of the table name, a Python DynamoDB Table object is created under a Python DynamoDB Database:

Python DynamoDB Database objects are only created if dynamodb tables are present in the results. A single Python DynamoDB Database object is created per project at most. No link is created between the artifact invoking table creation and the resulting table object. However, the bookmark of the table does reflect the corresponding method call.

When the name of a table is not resolved (either because of absence of information or technical limitations) a Python Unknown DynamoDB Table is created instead. A single unknown table is created per project.

Actions on DynamoDB tables

Only actions that have an impact on data in DynamoDB tables are modelized. These actions are represented with CRUD links. In the example below the method batch_write_item() of the low-level client object (DynamoDB) is called. This method can insert new table items or delete them, therefore the presence of the two link types (insertUseLink, deleteUseLink).

# sample_batch_write_item.py
import boto3

TABLE = 'fabric'
dynamodb = boto3.client('dynamodb')

def write_item():
    response = dynamodb.batch_write_item(
        RequestItems = {
          TABLE: [{"PutRequest": { "Item": { ... } }}]
        }
    )

Known Limitations

  • Accessing tables via tables collections such as “dynamodb.tables.all()” is not supported.
  • The query language PartiQL is not supported (and thus related API calls listed below).
  • The following methods might be supported in the future:
Non-supported Possible impact
batch_execute_statement() Missing CRUD links to tables (PartiQL)
execute_statement() Missing CRUD links to tables (PartiQL)
execute_transaction() Missing CRUD links to tables (PartiQL)
export_table_to_point_in_time() Missing link to S3 bucket
restore_table_from_backup() Missing table
restore_table_to_point_in_time() Missing table