Transaction API#

Spanner read-write transaction support.

class google.cloud.spanner.transaction.Transaction(session)[source]#

Bases: google.cloud.spanner.snapshot._SnapshotBase, google.cloud.spanner.batch._BatchBase

Implement read-write transaction semantics for a session.

begin()[source]#

Begin a transaction on the database.

Return type:bytes
Returns:the ID for the newly-begun transaction.
Raises:ValueError if the transaction is already begun, committed, or rolled back.
commit()[source]#

Commit mutations to the database.

Return type:datetime
Returns:timestamp of the committed changes.
Raises:ValueError if there are no mutations to commit.
committed = None#

Timestamp at which the transaction was successfully committed.

rollback()[source]#

Roll back a transaction on the database.