@@ -124,6 +124,9 @@ def open(cls, address, *, auth=None, timeout=None, **config):
124124 if config .protocol_version == (3 , 0 ):
125125 from neo4j .io ._bolt3 import Bolt3
126126 connection = Bolt3 (address , s , auth = auth , ** config )
127+ elif config .protocol_version == (4 , 0 ):
128+ from neo4j .io ._bolt4x0 import Bolt4x0
129+ connection = Bolt4x0 (address , s , auth = auth , ** config )
127130 else :
128131 log .debug ("[#%04X] S: <CLOSE>" , s .getpeername ()[1 ])
129132 s .shutdown (SHUT_RDWR )
@@ -160,17 +163,50 @@ def __enter__(self):
160163 def __exit__ (self , exc_type , exc_value , traceback ):
161164 self .close ()
162165
163- def run (self , statement , parameters = None , mode = None , bookmarks = None , metadata = None , timeout = None , ** handlers ):
164- raise NotImplementedError
166+ def run (self , statement , parameters = None , mode = None , bookmarks = None , metadata = None ,
167+ timeout = None , db = None , ** handlers ):
168+ """ Appends a RUN message to the output stream.
169+
170+ :param statement: Cypher query string
171+ :param parameters: dictionary of Cypher parameters
172+ :param mode: access mode for routing - "READ" or "WRITE" (default)
173+ :param bookmarks: iterable of bookmark values after which this transaction should begin
174+ :param metadata: custom metadata dictionary to attach to the transaction
175+ :param timeout: timeout for transaction execution (seconds)
176+ :param db: name of the database against which to begin the transaction
177+ :param handlers: handler functions passed into the returned Response object
178+ :return: Response object
179+ """
165180
166- def discard_all (self , ** handlers ):
167- raise NotImplementedError
181+ def discard (self , n = - 1 , qid = - 1 , ** handlers ):
182+ """ Appends a DISCARD message to the output stream.
168183
169- def pull_all (self , ** handlers ):
170- raise NotImplementedError
184+ :param n: number of records to discard, default = -1 (ALL)
185+ :param qid: query ID to discard for, default = -1 (last query)
186+ :param handlers: handler functions passed into the returned Response object
187+ :return: Response object
188+ """
171189
172- def begin (self , mode = None , bookmarks = None , metadata = None , timeout = None , ** handlers ):
173- raise NotImplementedError
190+ def pull (self , n = - 1 , qid = - 1 , ** handlers ):
191+ """ Appends a PULL message to the output stream.
192+
193+ :param n: number of records to pull, default = -1 (ALL)
194+ :param qid: query ID to pull for, default = -1 (last query)
195+ :param handlers: handler functions passed into the returned Response object
196+ :return: Response object
197+ """
198+
199+ def begin (self , mode = None , bookmarks = None , metadata = None , timeout = None , db = None , ** handlers ):
200+ """ Appends a BEGIN message to the output stream.
201+
202+ :param mode: access mode for routing - "READ" or "WRITE" (default)
203+ :param bookmarks: iterable of bookmark values after which this transaction should begin
204+ :param metadata: custom metadata dictionary to attach to the transaction
205+ :param timeout: timeout for transaction execution (seconds)
206+ :param db: name of the database against which to begin the transaction
207+ :param handlers: handler functions passed into the returned Response object
208+ :return: Response object
209+ """
174210
175211 def commit (self , ** handlers ):
176212 raise NotImplementedError
@@ -462,7 +498,7 @@ def fail(md):
462498 log .debug ("[#%04X] C: <ROUTING> query=%r" , cx .local_port , self .routing_context or {})
463499 cx .run ("CALL dbms.cluster.routing.getRoutingTable($context)" ,
464500 {"context" : self .routing_context }, on_success = metadata .update , on_failure = fail )
465- cx .pull_all (on_success = metadata .update , on_records = records .extend )
501+ cx .pull (on_success = metadata .update , on_records = records .extend )
466502 cx .send_all ()
467503 cx .fetch_all ()
468504 routing_info = [dict (zip (metadata .get ("fields" , ()), values )) for values in records ]
0 commit comments