DynamoDB class¶
-
class
ddbmock.database.db.
DynamoDB
¶ Main database, behaves as a singleton in the sense that all instances share the same data.
If underlying store supports it, all tables schema are persisted at creation time to a special table
~*schema*~
which is an invalid DynamoDB table name so no collisions are to be expected.
Constructors¶
Batch data manipulations¶
get_batch¶
-
DynamoDB.
get_batch
(batch)¶ Batch processor. Dispatches call to appropriate
ddbmock.database.table.Table
methods. This is the only low_level API that directly pushes throughput usage.Parameters: batch – raw DynamoDB request batch. Returns: dict compatible with DynamoDB API Raises: ddbmock.errors.ValidationException
if arange_key
was provided while table has none.Raises: ddbmock.errors.ResourceNotFoundException
if a table does not exist.
write_batch¶
-
DynamoDB.
write_batch
(batch)¶ Batch processor. Dispatches call to appropriate
ddbmock.database.table.Table
methods. This is the only low_level API that directly pushes throughput usage.Parameters: batch – raw DynamoDB request batch. Returns: dict compatible with DynamoDB API Raises: ddbmock.errors.ValidationException
if arange_key
was provided while table has none.Raises: ddbmock.errors.ResourceNotFoundException
if a table does not exist.
Database management¶
create_table¶
-
DynamoDB.
create_table
(name, data)¶ Create a
ddbmock.database.table.Table
named ‘name
‘’ using parameters provided indata
if it does not yet exist.Parameters: - name – Valid table name. No further checks are performed.
- data – raw DynamoDB request data.
Returns: A reference to the newly created
ddbmock.database.table.Table
Raises: ddbmock.errors.ResourceInUseException
if the table already exists.Raises: ddbmock.errors.LimitExceededException
if more thanddbmock.config.MAX_TABLES
already exist.
delete_table¶
-
DynamoDB.
delete_table
(name)¶ Triggers internal “realistic” table deletion. This implies changing the status to
DELETING
. Once :py:const:ddbmock.config.DELAY_DELETING has expired :py:meth:_internal_delete_table is called and the table is de-referenced from :py:attr:data.Since :py:attr:data only holds a reference, the table object might still exist at that moment and possibly still handle pending requests. This also allows to safely return a handle to the table object.
Parameters: name – Valid table name. Returns: A reference to ddbmock.database.table.Table
namedname
get_table¶
-
DynamoDB.
get_table
(name)¶ Get a handle to
ddbmock.database.table.Table
‘name
‘ is it exists.Parameters: name – Name of the table to load. Returns: ddbmock.database.table.Table
with name ‘name
‘Raises: ddbmock.errors.ResourceNotFoundException
if the table does not exist.