@@ -134,10 +134,6 @@ def driver(cls, uri, *, auth=None, **config):
134
134
URI_SCHEME_NEO4J_SELF_SIGNED_CERTIFICATE ,
135
135
URI_SCHEME_NEO4J_SECURE ,
136
136
)
137
- from neo4j .conf import (
138
- TRUST_ALL_CERTIFICATES ,
139
- TRUST_SYSTEM_CA_SIGNED_CERTIFICATES
140
- )
141
137
142
138
driver_type , security_type , parsed = parse_neo4j_uri (uri )
143
139
@@ -252,8 +248,7 @@ def parse_targets(cls, *targets):
252
248
targets = " " .join (targets )
253
249
if not targets :
254
250
targets = cls .default_targets
255
- addresses = Address .parse_list (targets , default_host = cls .default_host ,
256
- default_port = cls .default_port )
251
+ addresses = Address .parse_list (targets , default_host = cls .default_host , default_port = cls .default_port )
257
252
return addresses
258
253
259
254
@@ -314,6 +309,26 @@ def verify_connectivity(self, **config):
314
309
"""
315
310
raise NotImplementedError
316
311
312
+ @experimental ("Feature support query, based on Bolt Protocol Version and Neo4j Server Version will change in the future." )
313
+ def supports_multi_db (self ):
314
+ """ Check if the server or cluster supports multi-databases.
315
+
316
+ :return: Returns true if the server or cluster the driver connects to supports multi-databases, otherwise false.
317
+ :rtype: bool
318
+ """
319
+ from neo4j .io ._bolt4x0 import Bolt4x0
320
+
321
+ multi_database = False
322
+ cx = self ._pool .acquire (access_mode = READ_ACCESS , timeout = self ._pool .workspace_config .connection_acquisition_timeout , database = self ._pool .workspace_config .database )
323
+
324
+ # TODO: This logic should be inside the Bolt subclasses, because it can change depending on Bolt Protocol Version.
325
+ if cx .PROTOCOL_VERSION >= Bolt4x0 .PROTOCOL_VERSION and cx .server_info .version_info () >= Version (4 , 0 , 0 ):
326
+ multi_database = True
327
+
328
+ self ._pool .release (cx )
329
+
330
+ return multi_database
331
+
317
332
318
333
class BoltDriver (Direct , Driver ):
319
334
""" A :class:`.BoltDriver` is created from a ``bolt`` URI and addresses
@@ -326,10 +341,18 @@ class BoltDriver(Direct, Driver):
326
341
327
342
@classmethod
328
343
def open (cls , target , * , auth = None , ** config ):
344
+ """
345
+ :param target:
346
+ :param auth:
347
+ :param config: The values that can be specified are found in :class: `neo4j.PoolConfig` and :class: `neo4j.WorkspaceConfig`
348
+
349
+ :return:
350
+ :rtype: :class: `neo4j.BoltDriver`
351
+ """
329
352
from neo4j .io import BoltPool
330
353
address = cls .parse_target (target )
331
354
pool_config , default_workspace_config = Config .consume_chain (config , PoolConfig , WorkspaceConfig )
332
- pool = BoltPool .open (address , auth = auth , ** pool_config )
355
+ pool = BoltPool .open (address , auth = auth , pool_config = pool_config , workspace_config = default_workspace_config )
333
356
return cls (pool , default_workspace_config )
334
357
335
358
def __init__ (self , pool , default_workspace_config ):
@@ -338,6 +361,12 @@ def __init__(self, pool, default_workspace_config):
338
361
self ._default_workspace_config = default_workspace_config
339
362
340
363
def session (self , ** config ):
364
+ """
365
+ :param config: The values that can be specified are found in :class: `neo4j.SessionConfig`
366
+
367
+ :return:
368
+ :rtype: :class: `neo4j.Session`
369
+ """
341
370
from neo4j .work .simple import Session
342
371
session_config = SessionConfig (self ._default_workspace_config , config )
343
372
SessionConfig .consume (config ) # Consume the config
@@ -372,16 +401,15 @@ def open(cls, *targets, auth=None, routing_context=None, **config):
372
401
from neo4j .io import Neo4jPool
373
402
addresses = cls .parse_targets (* targets )
374
403
pool_config , default_workspace_config = Config .consume_chain (config , PoolConfig , WorkspaceConfig )
375
- pool = Neo4jPool .open (* addresses , auth = auth , routing_context = routing_context , ** pool_config )
404
+ pool = Neo4jPool .open (* addresses , auth = auth , routing_context = routing_context , pool_config = pool_config , workspace_config = default_workspace_config )
376
405
return cls (pool , default_workspace_config )
377
406
378
407
def __init__ (self , pool , default_workspace_config ):
379
- Routing .__init__ (self , pool .routing_table . initial_routers )
408
+ Routing .__init__ (self , pool .get_default_database_initial_router_addresses () )
380
409
Driver .__init__ (self , pool )
381
410
self ._default_workspace_config = default_workspace_config
382
411
383
412
def session (self , ** config ):
384
- from neo4j .work .simple import Session
385
413
session_config = SessionConfig (self ._default_workspace_config , config )
386
414
SessionConfig .consume (config ) # Consume the config
387
415
return Session (self ._pool , session_config )
@@ -392,9 +420,6 @@ def pipeline(self, **config):
392
420
PipelineConfig .consume (config ) # Consume the config
393
421
return Pipeline (self ._pool , pipeline_config )
394
422
395
- def get_routing_table (self ):
396
- return self ._pool .routing_table
397
-
398
423
def verify_connectivity (self , ** config ):
399
424
"""
400
425
:raise ServiceUnavailable: raised if the server does not support routing or if routing support is broken.
@@ -406,11 +431,11 @@ def _verify_routing_connectivity(self):
406
431
from neo4j .exceptions import ServiceUnavailable
407
432
from neo4j ._exceptions import BoltHandshakeError
408
433
409
- table = self .get_routing_table ()
434
+ table = self ._pool . get_routing_table_for_default_database ()
410
435
routing_info = {}
411
436
for ix in list (table .routers ):
412
437
try :
413
- routing_info [ix ] = self ._pool .fetch_routing_info (table .routers [0 ])
438
+ routing_info [ix ] = self ._pool .fetch_routing_info (address = table .routers [0 ], timeout = self . _default_workspace_config . connection_acquisition_timeout , database = self . _default_workspace_config . database )
414
439
except BoltHandshakeError as error :
415
440
routing_info [ix ] = None
416
441
0 commit comments