File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ Example Usage
3131 result = session.run(" MATCH (a:Person) RETURN a.name AS name" )
3232 for record in result:
3333 print (record[" name" ])
34- result.close()
3534 session.close()
3635
3736
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