File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ client.alter(op)
9292To create a transaction, call ` DgraphClient#txn() ` method, which returns a
9393new ` 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
9696the transaction. Calling ` Txn#discard() ` after ` Txn#commit() ` is a no-op
9797and 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,
You can’t perform that action at this time.
0 commit comments