@@ -134,10 +134,6 @@ def driver(cls, uri, *, auth=None, **config):
134134 URI_SCHEME_NEO4J_SELF_SIGNED_CERTIFICATE ,
135135 URI_SCHEME_NEO4J_SECURE ,
136136 )
137- from neo4j .conf import (
138- TRUST_ALL_CERTIFICATES ,
139- TRUST_SYSTEM_CA_SIGNED_CERTIFICATES
140- )
141137
142138 driver_type , security_type , parsed = parse_neo4j_uri (uri )
143139
@@ -252,8 +248,7 @@ def parse_targets(cls, *targets):
252248 targets = " " .join (targets )
253249 if not targets :
254250 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 )
257252 return addresses
258253
259254
@@ -314,6 +309,26 @@ def verify_connectivity(self, **config):
314309 """
315310 raise NotImplementedError
316311
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+
317332
318333class BoltDriver (Direct , Driver ):
319334 """ A :class:`.BoltDriver` is created from a ``bolt`` URI and addresses
@@ -326,10 +341,18 @@ class BoltDriver(Direct, Driver):
326341
327342 @classmethod
328343 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+ """
329352 from neo4j .io import BoltPool
330353 address = cls .parse_target (target )
331354 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 )
333356 return cls (pool , default_workspace_config )
334357
335358 def __init__ (self , pool , default_workspace_config ):
@@ -338,6 +361,12 @@ def __init__(self, pool, default_workspace_config):
338361 self ._default_workspace_config = default_workspace_config
339362
340363 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+ """
341370 from neo4j .work .simple import Session
342371 session_config = SessionConfig (self ._default_workspace_config , config )
343372 SessionConfig .consume (config ) # Consume the config
@@ -372,16 +401,15 @@ def open(cls, *targets, auth=None, routing_context=None, **config):
372401 from neo4j .io import Neo4jPool
373402 addresses = cls .parse_targets (* targets )
374403 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 )
376405 return cls (pool , default_workspace_config )
377406
378407 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 () )
380409 Driver .__init__ (self , pool )
381410 self ._default_workspace_config = default_workspace_config
382411
383412 def session (self , ** config ):
384- from neo4j .work .simple import Session
385413 session_config = SessionConfig (self ._default_workspace_config , config )
386414 SessionConfig .consume (config ) # Consume the config
387415 return Session (self ._pool , session_config )
@@ -392,9 +420,6 @@ def pipeline(self, **config):
392420 PipelineConfig .consume (config ) # Consume the config
393421 return Pipeline (self ._pool , pipeline_config )
394422
395- def get_routing_table (self ):
396- return self ._pool .routing_table
397-
398423 def verify_connectivity (self , ** config ):
399424 """
400425 :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):
406431 from neo4j .exceptions import ServiceUnavailable
407432 from neo4j ._exceptions import BoltHandshakeError
408433
409- table = self .get_routing_table ()
434+ table = self ._pool . get_routing_table_for_default_database ()
410435 routing_info = {}
411436 for ix in list (table .routers ):
412437 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 )
414439 except BoltHandshakeError as error :
415440 routing_info [ix ] = None
416441
0 commit comments