@@ -5,7 +5,8 @@ A :class:`~google.cloud.spanner_v1.transaction.Transaction` represents a
55transaction: when the transaction commits, it will send any accumulated
66mutations to the server.
77
8- To understand more about how transactions work, visit [Transaction](https://cloud.google.com/spanner/docs/reference/rest/v1/Transaction).
8+ To understand more about how transactions work, visit
9+ `Transaction <https://cloud.google.com/spanner/docs/reference/rest/v1/Transaction >`_.
910To learn more about how to use them in the Python client, continue reading.
1011
1112
@@ -90,8 +91,8 @@ any of the records already exists.
9091Update records using a Transaction
9192----------------------------------
9293
93- :meth: `Transaction.update ` updates one or more existing records in a table. Fails
94- if any of the records does not already exist.
94+ :meth: `Transaction.update ` updates one or more existing records in a table.
95+ Fails if any of the records does not already exist.
9596
9697.. code :: python
9798
@@ -178,35 +179,40 @@ Using :meth:`~Database.run_in_transaction`
178179
179180Rather than calling :meth: `~Transaction.commit ` or :meth: `~Transaction.rollback `
180181manually, you should use :meth: `~Database.run_in_transaction ` to run the
181- function that you need. The transaction's :meth: `~Transaction.commit ` method
182+ function that you need. The transaction's :meth: `~Transaction.commit ` method
182183will be called automatically if the ``with `` block exits without raising an
183- exception. The function will automatically be retried for
184+ exception. The function will automatically be retried for
184185:class: `~google.api_core.exceptions.Aborted ` errors, but will raise on
185186:class: `~google.api_core.exceptions.GoogleAPICallError ` and
186187:meth: `~Transaction.rollback ` will be called on all others.
187188
188189.. code :: python
189190
190191 def _unit_of_work (transaction ):
191-
192192 transaction.insert(
193- ' citizens' , columns = [' email' , ' first_name' , ' last_name' , ' age' ],
193+ ' citizens' ,
194+ columns = [' email' , ' first_name' , ' last_name' , ' age' ],
194195 values = [
195196 [' phred@exammple.com' , ' Phred' , ' Phlyntstone' , 32 ],
196197 [' bharney@example.com' , ' Bharney' , ' Rhubble' , 31 ],
197- ])
198+ ]
199+ )
198200
199201 transaction.update(
200- ' citizens' , columns = [' email' , ' age' ],
202+ ' citizens' ,
203+ columns = [' email' , ' age' ],
201204 values = [
202205 [' phred@exammple.com' , 33 ],
203206 [' bharney@example.com' , 32 ],
204- ])
207+ ]
208+ )
205209
206210 ...
207211
208- transaction.delete(' citizens' ,
209- keyset[' bharney@example.com' , ' nonesuch@example.com' ])
212+ transaction.delete(
213+ ' citizens' ,
214+ keyset = [' bharney@example.com' , ' nonesuch@example.com' ]
215+ )
210216
211217 db.run_in_transaction(_unit_of_work)
212218
@@ -242,7 +248,7 @@ If an exception is raised inside the ``with`` block, the transaction's
242248 ...
243249
244250 transaction.delete(' citizens' ,
245- keyset[' bharney@example.com' , ' nonesuch@example.com' ])
251+ keyset = [' bharney@example.com' , ' nonesuch@example.com' ])
246252
247253
248254 Begin a Transaction
0 commit comments