File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -176,9 +176,9 @@ def test_transaction_commit(self):
176
176
driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token )
177
177
session = driver .session ()
178
178
# tag::transaction-commit[]
179
- tx = session .begin_transaction ()
180
- tx .run ("CREATE (:Person {name: 'Guinevere'})" )
181
- tx .commit ()
179
+ with session .begin_transaction () as tx :
180
+ tx .run ("CREATE (:Person {name: 'Guinevere'})" )
181
+ tx .success = True
182
182
# end::transaction-commit[]
183
183
result = session .run ("MATCH (p:Person {name: 'Guinevere'}) RETURN count(p)" )
184
184
record = next (iter (result ))
@@ -189,9 +189,9 @@ def test_transaction_rollback(self):
189
189
driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token )
190
190
session = driver .session ()
191
191
# tag::transaction-rollback[]
192
- tx = session .begin_transaction ()
193
- tx .run ("CREATE (:Person {name: 'Merlin'})" )
194
- tx .rollback ()
192
+ with session .begin_transaction () as tx :
193
+ tx .run ("CREATE (:Person {name: 'Merlin'})" )
194
+ tx .success = False
195
195
# end::transaction-rollback[]
196
196
result = session .run ("MATCH (p:Person {name: 'Merlin'}) RETURN count(p)" )
197
197
record = next (iter (result ))
You can’t perform that action at this time.
0 commit comments