azure.storage.table.tablebatch module

class azure.storage.table.tablebatch.TableBatch(require_encryption=False, key_encryption_key=None, encryption_resolver=None)[source]

Bases: object

This is the class that is used for batch operation for storage table service.

The Table service supports batch transactions on entities that are in the same table and belong to the same partition group. Multiple operations are supported within a single transaction. The batch can include at most 100 entities, and its total payload may be no more than 4 MB in size.

delete_entity(partition_key, row_key, if_match='*')[source]

Adds a delete entity operation to the batch. See delete_entity() for more information on deletes.

The operation will not be executed until the batch is committed.

Parameters:
  • partition_key (str) – The PartitionKey of the entity.
  • row_key (str) – The RowKey of the entity.
  • if_match (str) – The client may specify the ETag for the entity on the request in order to compare to the ETag maintained by the service for the purpose of optimistic concurrency. The delete operation will be performed only if the ETag sent by the client matches the value maintained by the server, indicating that the entity has not been modified since it was retrieved by the client. To force an unconditional delete, set If-Match to the wildcard character (*).
insert_entity(entity)[source]

Adds an insert entity operation to the batch. See insert_entity() for more information on inserts.

The operation will not be executed until the batch is committed.

Parameters:entity (a dict or azure.storage.table.models.Entity) – The entity to insert. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey.
insert_or_merge_entity(entity)[source]

Adds an insert or merge entity operation to the batch. See insert_or_merge_entity() for more information on insert or merge operations.

The operation will not be executed until the batch is committed.

Parameters:entity (a dict or azure.storage.table.models.Entity) – The entity to insert or merge. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey.
insert_or_replace_entity(entity)[source]

Adds an insert or replace entity operation to the batch. See insert_or_replace_entity() for more information on insert or replace operations.

The operation will not be executed until the batch is committed.

Parameters:entity (a dict or azure.storage.table.models.Entity) – The entity to insert or replace. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey.
merge_entity(entity, if_match='*')[source]

Adds a merge entity operation to the batch. See merge_entity() for more information on merges.

The operation will not be executed until the batch is committed.

Parameters:
  • entity (a dict or azure.storage.table.models.Entity) – The entity to merge. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey.
  • if_match (str) – The client may specify the ETag for the entity on the request in order to compare to the ETag maintained by the service for the purpose of optimistic concurrency. The merge operation will be performed only if the ETag sent by the client matches the value maintained by the server, indicating that the entity has not been modified since it was retrieved by the client. To force an unconditional merge, set If-Match to the wildcard character (*).
update_entity(entity, if_match='*')[source]

Adds an update entity operation to the batch. See update_entity() for more information on updates.

The operation will not be executed until the batch is committed.

Parameters:
  • entity (a dict or azure.storage.table.models.Entity) – The entity to update. Could be a dict or an entity object. Must contain a PartitionKey and a RowKey.
  • if_match (str) – The client may specify the ETag for the entity on the request in order to compare to the ETag maintained by the service for the purpose of optimistic concurrency. The update operation will be performed only if the ETag sent by the client matches the value maintained by the server, indicating that the entity has not been modified since it was retrieved by the client. To force an unconditional update, set If-Match to the wildcard character (*).