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):
176176 driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token )
177177 session = driver .session ()
178178 # 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
182182 # end::transaction-commit[]
183183 result = session .run ("MATCH (p:Person {name: 'Guinevere'}) RETURN count(p)" )
184184 record = next (iter (result ))
@@ -189,9 +189,9 @@ def test_transaction_rollback(self):
189189 driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token )
190190 session = driver .session ()
191191 # 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
195195 # end::transaction-rollback[]
196196 result = session .run ("MATCH (p:Person {name: 'Merlin'}) RETURN count(p)" )
197197 record = next (iter (result ))
You can’t perform that action at this time.
0 commit comments