Skip to content

Commit a619d0a

Browse files
author
James William Pye
committed
Rework the transaction documentation a bit.
Discuss the transaction configuration before talking about the interface points.
1 parent c74929a commit a619d0a

1 file changed

Lines changed: 31 additions & 28 deletions

File tree

postgresql/documentation/driver.py

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@
11821182
**Using the with-statement syntax for managing transactions is strongly
11831183
recommended.** By using the transaction's context manager, it allows for Python
11841184
exceptions to be properly treated as fatal to the transaction as when an
1185-
exception of any kind occurs within a transaction block, it is unlikely that
1185+
uncaught exception of any kind occurs within the block, it is unlikely that
11861186
the state of the transaction can be trusted. Additionally, the ``__exit__``
11871187
method provides a safe-guard against invalid commits. This can occur if a
11881188
database error is inappropriately caught within a block without being raised.
@@ -1191,6 +1191,36 @@
11911191
instruction methods provided by `postgresql.api.Transaction` objects.
11921192
11931193
1194+
Transaction Configuration
1195+
-------------------------
1196+
1197+
Keyword arguments given to ``xact()`` provide the means for configuring the
1198+
properties of the transaction. Only three points of configuration are available:
1199+
1200+
``gid``
1201+
The global identifier to use. Identifies the transaction as using two-phase
1202+
commit. The ``prepare()`` method *must* be called prior to ``commit()`` or
1203+
``__exit__()``.
1204+
1205+
``isolation``
1206+
The isolation level of the transaction. This must be a string. It will be
1207+
interpolated directly into the START TRANSACTION statement. Normally,
1208+
'SERIALIZABLE' or 'READ COMMITTED':
1209+
1210+
>>> with db.xact(isolation = 'SERIALIZABLE'):
1211+
... ...
1212+
1213+
``mode``
1214+
A string, 'READ ONLY' or 'READ WRITE'. States the mutability of stored
1215+
information in the database. Like ``isolation``, this is interpolated
1216+
directly into the START TRANSACTION string.
1217+
1218+
The specification of any of these transaction properties imply that the transaction
1219+
is a block. Savepoints do not take configuration, so if a transaction identified
1220+
as a block is started while another block is running, an exception will be
1221+
raised.
1222+
1223+
11941224
Transaction Interface Points
11951225
----------------------------
11961226
@@ -1269,33 +1299,6 @@
12691299
property on the raised exception.
12701300
12711301
1272-
Transaction Configuration
1273-
-------------------------
1274-
1275-
Keyword arguments given to ``xact()`` provide the means for configuring the
1276-
properties of the transaction. Only three points of configuration are available:
1277-
1278-
``gid``
1279-
The global identifier to use. Identifies the transaction as using two-phase
1280-
commit. The ``prepare()`` method *must* be called prior to ``commit()`` or
1281-
``__exit__()``.
1282-
1283-
``isolation``
1284-
The isolation level of the transaction. This must be a string. It will be
1285-
interpolated directly into the START TRANSACTION statement. Normally,
1286-
'SERIALIZABLE' or 'READ COMMITTED'.
1287-
1288-
``mode``
1289-
A string, 'READ ONLY' or 'READ WRITE'. States the mutability of stored
1290-
information in the database. Like ``isolation``, this is interpolated
1291-
directly into the START TRANSACTION string.
1292-
1293-
The specification of any of these transaction properties imply that the transaction
1294-
is a block. Savepoints do not take configuration, so if a transaction identified
1295-
as a block is started while another block is running, an exception will be
1296-
raised.
1297-
1298-
12991302
Prepared Transactions
13001303
---------------------
13011304

0 commit comments

Comments
 (0)