@@ -68,7 +68,6 @@ def NewSession(backend, data):
68
68
69
69
def SessionRun (backend , data ):
70
70
session = backend .sessions [data ["sessionId" ]].session
71
- print (data )
72
71
cypher , params = fromtestkit .toCypherAndParams (data )
73
72
# TODO: txMeta, timeout
74
73
result = session .run (cypher , parameters = params )
@@ -85,10 +84,47 @@ def SessionClose(backend, data):
85
84
backend .send_response ("Session" , {"id" : key })
86
85
87
86
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
+
88
100
def ResultNext (backend , data ):
89
101
result = backend .results [data ["resultId" ]]
90
102
try :
91
103
record = next (iter (result ))
92
104
except StopIteration :
93
105
backend .send_response ("NullRecord" , {})
94
106
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