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)
92
92
To create a transaction, call ` DgraphClient#txn() ` method, which returns a
93
93
new ` Txn ` object. This operation incurs no network overhead.
94
94
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
96
96
the transaction. Calling ` Txn#discard() ` after ` Txn#commit() ` is a no-op
97
97
and you can call ` Txn#discard() ` multiple times with no additional side-effects.
98
98
@@ -106,6 +106,22 @@ finally:
106
106
# ...
107
107
```
108
108
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
+
109
125
### Run a mutation
110
126
111
127
` 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