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.Tablemethods. 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.ValidationExceptionif arange_keywas provided while table has none.Raises: ddbmock.errors.ResourceNotFoundExceptionif a table does not exist.
write_batch¶
-
DynamoDB.write_batch(batch)¶ Batch processor. Dispatches call to appropriate
ddbmock.database.table.Tablemethods. 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.ValidationExceptionif arange_keywas provided while table has none.Raises: ddbmock.errors.ResourceNotFoundExceptionif a table does not exist.
Database management¶
create_table¶
-
DynamoDB.create_table(name, data)¶ Create a
ddbmock.database.table.Tablenamed ‘name‘’ using parameters provided indataif 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.TableRaises: ddbmock.errors.ResourceInUseExceptionif the table already exists.Raises: ddbmock.errors.LimitExceededExceptionif more thanddbmock.config.MAX_TABLESalready 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.Tablenamedname
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.Tablewith name ‘name‘Raises: ddbmock.errors.ResourceNotFoundExceptionif the table does not exist.