Skip to content

Commit 434f59e

Browse files
authored
Merge 6455329 into 75ad001
2 parents 75ad001 + 6455329 commit 434f59e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ client.alter(op)
9292
To create a transaction, call `DgraphClient#txn()` method, which returns a
9393
new `Txn` object. This operation incurs no network overhead.
9494

95-
It is good practise to call `Txn#discard()` in a `finally` block after running
95+
It is good practice to call `Txn#discard()` in a `finally` block after running
9696
the transaction. Calling `Txn#discard()` after `Txn#commit()` is a no-op
9797
and you can call `Txn#discard()` multiple times with no additional side-effects.
9898

@@ -106,6 +106,22 @@ finally:
106106
# ...
107107
```
108108

109+
To create a read-only transaction, call `DgraphClient#txn(read_only=True)`.
110+
Read-only transactions are ideal for transactions which only involve queries.
111+
Mutations and commits are not allowed.
112+
113+
```python
114+
txn = client.txn(read_only=True)
115+
try:
116+
# Do some queries here
117+
# ...
118+
finally:
119+
txn.discard()
120+
# ...
121+
```
122+
123+
`client.query()` uses a read-only transaction to execute the query.
124+
109125
### Run a mutation
110126

111127
`Txn#mutate(mu=Mutation)` runs a mutation. It takes in a `Mutation` object,

0 commit comments

Comments
 (0)