@@ -68,7 +68,6 @@ def NewSession(backend, data):
6868
6969def SessionRun (backend , data ):
7070 session = backend .sessions [data ["sessionId" ]].session
71- print (data )
7271 cypher , params = fromtestkit .toCypherAndParams (data )
7372 # TODO: txMeta, timeout
7473 result = session .run (cypher , parameters = params )
@@ -85,10 +84,47 @@ def SessionClose(backend, data):
8584 backend .send_response ("Session" , {"id" : key })
8685
8786
87+ def SessionBeginTransaction (backend , data ):
88+ key = data ["sessionId" ]
89+ session = backend .sessions [key ].session
90+ metadata = data .get ('txMeta' , None )
91+ timeout = data .get ('timeout' , None )
92+ if timeout :
93+ timeout = int (timeout )
94+ tx = session .begin_transaction (metadata = metadata , timeout = timeout )
95+ key = backend .next_key ()
96+ backend .transactions [key ] = tx
97+ backend .send_response ("Transaction" , {"id" : key })
98+
99+
88100def ResultNext (backend , data ):
89101 result = backend .results [data ["resultId" ]]
90102 try :
91103 record = next (iter (result ))
92104 except StopIteration :
93105 backend .send_response ("NullRecord" , {})
94106 backend .send_response ("Record" , totestkit .record (record ))
107+
108+
109+ def TransactionRun (backend , data ):
110+ key = data ["txId" ]
111+ tx = backend .transactions [key ]
112+ cypher , params = fromtestkit .toCypherAndParams (data )
113+ result = tx .run (cypher , parameters = params )
114+ key = backend .next_key ()
115+ backend .results [key ] = result
116+ backend .send_response ("Result" , {"id" : key })
117+
118+
119+ def TransactionCommit (backend , data ):
120+ key = data ["txId" ]
121+ tx = backend .transactions [key ]
122+ tx .commit ()
123+ backend .send_response ("Transaction" , {"id" : key })
124+
125+
126+ def TransactionRollback (backend , data ):
127+ key = data ["txId" ]
128+ tx = backend .transactions [key ]
129+ tx .rollback ()
130+ backend .send_response ("Transaction" , {"id" : key })
0 commit comments