
    Rǻi                       d dl mZ d dlZd dlmZ ddlmZ ddlm	Z	 ddl
mZmZmZmZmZmZmZmZmZ ddlmZmZmZmZmZmZ dd	lmZ dd
lmZm Z m!Z! ddl"m#Z#m$Z$m%Z% ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3 ddl4m5Z5m6Z6m7Z7m8Z8 ddl9m:Z:m;Z; ddl4m<Z< ddl=m>Z>m?Z@mAZB ddlCmDZD ddlEmFZFmGZGmHZH ej                  r,d dlJZJd dlKmLZL ddl
mMZMmNZNmOZO  G d deL      ZPePj                  ZRn eS       ZR ej                  d      ZU G d d      ZV G d d      ZW G d d      ZX G d d       ZY	 	 	 	 	 	 	 	 	 	 d)d!Z" G d" d#eWeY      ZZ G d$ d%eXeY      Z[d&d'd(Z\y)*    )annotationsN)NoneType   )_typing)Address)	DRIVER_BOLTDRIVER_NEO4JNotificationMinimumSeverityparse_neo4j_uriparse_routing_contextRoutingControlSECURITY_TYPE_SECURE%SECURITY_TYPE_SELF_SIGNED_CERTIFICATETelemetryAPI)ConfigConfigurationErrorSessionConfigTrustAll
TrustStoreWorkspaceConfig)ENABLED)deprecation_warnpreview_warnunclosed_resource_warn)EagerResultQueryunit_of_work)_TAuthAuthBookmarkManager	BookmarksREAD_ACCESS
ServerInfoURI_SCHEME_BOLTURI_SCHEME_BOLT_SECURE'URI_SCHEME_BOLT_SELF_SIGNED_CERTIFICATEURI_SCHEME_NEO4JURI_SCHEME_NEO4J_SECURE(URI_SCHEME_NEO4J_SELF_SIGNED_CERTIFICATEWRITE_ACCESS)AuthManagerAuthManagersClientCertificateClientCertificateProvider)DriverError
Neo4jError   ) _StaticClientCertificateProvider)Neo4jBookmarkManagerTBmConsumerTBmSupplier)
PoolConfig)ManagedTransactionResultSession)Enum)$T_NotificationDisabledClassificationT_NotificationMinimumSeverityT_RoutingControlc                      e Zd ZdZy)_DefaultEnumdefaultN)__name__
__module____qualname__r@        P/opt/lhia/marcimex/agent/venv/lib/python3.12/site-packages/neo4j/_sync/driver.pyr?   r?   g   s    rE   r?   _Tc                  T   e Zd ZdZej
                  r`edddddddddddddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Znedd	 	 	 	 	 dd       Ze	 	 	 d	 	 	 	 	 	 	 dd       Zed	        Z	edd
       Z
y)GraphDatabasez0Accessor for :class:`neo4j.Driver` construction..)authmax_connection_lifetimeliveness_check_timeoutmax_connection_pool_sizeconnection_timeoutconnection_write_timeoutresolver	encryptedtrusted_certificatesclient_certificatessl_context
user_agent
keep_alivenotifications_min_severity!notifications_disabled_categories&notifications_disabled_classificationswarn_notification_severitytelemetry_disabledmax_transaction_retry_timeconnection_acquisition_timeoutinitial_retry_delayretry_delay_multiplierretry_delay_jitter_factordatabase
fetch_sizeimpersonated_userbookmark_managerc                    y NrD   )clsurirJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   s                                rF   driverzGraphDatabase.driverw   s    d rE   N)rJ   c          	        t        |      \  }}}t        |t              st        j                  |      }||d<   |j                  d      }t        |t              rt        |      |d<   d|v r9t        |d   t              s&t        dj                  t        |d                     |t        t        hv rEd|v sd|v sd|v r9t        dj                  t        t        gt         t"        t$        t&        g            |t        k(  rd|d<   n|t        k(  rd|d<   t)               |d<   d	|v rt+        d
d       t-        |d       |j                  d      }||dk  rt        d| d      |t.        t0        hv sJ |t.        k(  rAt3        |j4                        rt        d|d       | j6                  |j8                  fi |S t3        |j4                        }	 | j:                  |j8                  fd|	i|S )a  
            Create a driver.

            :param uri: the connection URI for the driver,
                see :ref:`uri-ref` for available URIs.
            :param auth: the authentication details,
                see :ref:`auth-ref` for available authentication details.
            :param config: driver configuration key-word arguments,
                see :ref:`driver-configuration-ref` for available
                key-word arguments.
            rJ   rS   rR   zThe config setting "trusted_certificates" must be of type neo4j.TrustAll, neo4j.TrustCustomCAs, orneo4j.TrustSystemCAs but was {}rQ   rT   zThe config settings "encrypted", "trusted_certificates", and "ssl_context" can only be used with the URI schemes {!r}. Use the other URI schemes {!r} for setting encryption settings.TrX   dnotifications_disabled_categories is deprecated, use notifications_disabled_classifications instead.r   stack_leveldriver_levelrL   r   zWThe config setting "liveness_check_timeout" must be greater than or equal to 0 but was .zrRouting context (URI query parameters) are not supported by direct drivers ("bolt[+s[sc]]://" scheme). Given URI: routing_context)r   
isinstancer+   r,   staticgetr-   r2   r   r   formattyper   r   r$   r'   r&   r%   r)   r(   r   r   _normalize_notifications_configr   r	   r   query_bolt_drivernetloc_neo4j_driver)
rg   rh   rJ   configdriver_typesecurity_typeparsedrS   rL   rq   s
             rF   ri   zGraphDatabase.driver   sW   & 2A1E.KdK0#**40!F6N!',@!A,.?@ 55GH +, &/
-.
9 )66<fV$:;<7  5$!  v%)V3 F*(+ ,26+,
 D2D3	,	 $  44&*{#"GG&*{#19-.2f< J !
 ,FF%+ZZ0H%I"&2*Q.(:-.a1  ;"====k)(6,BBEK 
 (s''@@@3FLLAO$3$$/>BH rE   c                    t        |t        t        f      sLt        dd       t        j                  t        j                  t
        j                  t           |            }n|}t        |||      S )a  
        Create a :class:`.BookmarkManager` with default implementation.

        Basic usage example to configure sessions with the built-in bookmark
        manager implementation so that all work is automatically causally
        chained (i.e., all reads can observe all previous writes even in a
        clustered setup)::

            import neo4j


            # omitting closing the driver for brevity
            driver = neo4j.GraphDatabase.driver(...)
            bookmark_manager = neo4j.GraphDatabase.bookmark_manager(...)

            with (
                driver.session(bookmark_manager=bookmark_manager) as session1,
                driver.session(
                    bookmark_manager=bookmark_manager,
                    default_access_mode=neo4j.READ_ACCESS,
                ) as session2,
            ):
                result1 = session1.run("<WRITE_QUERY>")
                result1.consume()
                # READ_QUERY is guaranteed to see what WRITE_QUERY wrote.
                result2 = session2.run("<READ_QUERY>")
                result2.consume()

        This is a very contrived example, and in this particular case, having
        both queries in the same session has the exact same effect and might
        even be more performant. However, when dealing with sessions spanning
        multiple threads, Tasks, processes, or even hosts, the bookmark
        manager can come in handy as sessions are not safe to be used
        concurrently.

        :param initial_bookmarks:
            The initial set of bookmarks. The returned bookmark manager will
            use this to initialize its internal bookmarks.

            .. deprecated:: 6.0
                Passing raw string bookmarks is deprecated.
                Use a :class:`.Bookmarks` object instead.

        :param bookmarks_supplier:
            Function which will be called every time the default bookmark
            manager's method :meth:`.BookmarkManager.get_bookmarks`
            gets called.
            The function takes no arguments and must return a
            :class:`.Bookmarks` object. The result of ``bookmarks_supplier``
            will then be concatenated with the internal set of bookmarks and
            used to configure the session in creation. It will, however, not
            update the internal set of bookmarks.
        :param bookmarks_consumer:
            Function which will be called whenever the set of bookmarks
            handled by the bookmark manager gets updated with the new
            internal bookmark set. It will receive the new set of bookmarks
            as a :class:`.Bookmarks` object and return :data:`None`.

        :returns: A default implementation of :class:`.BookmarkManager`.

        .. versionadded:: 5.0

        .. versionchanged:: 5.3
            The bookmark manager no longer tracks bookmarks per database.
            This effectively changes the signature of almost all bookmark
            manager related methods:

            * ``initial_bookmarks`` is no longer a mapping from database name
              to bookmarks but plain bookmarks.
            * ``bookmarks_supplier`` no longer receives the database name as
              an argument.
            * ``bookmarks_consumer`` no longer receives the database name as
              an argument.

        .. versionchanged:: 5.8 Stabilized from experimental.

        .. versionchanged:: 6.0
            Deprecated passing raw string bookmarks as initial_bookmarks.
        zWPassing raw strings as initial_bookmarks is deprecated. Use a Bookmarks object instead.r   rl   )initial_bookmarksbookmarks_supplierbookmarks_consumer)
rr   r!   r   r   from_raw_valuestcastIterablestrr3   )rg   r   r   r   cast_initial_bookmarkss        rF   rd   zGraphDatabase.bookmark_manager  so    p +i-BC6  &/%>%>qzz#(9:&" &7"#411
 	
rE   c                    ddl m}m} 	 t        j                  |fi |S # ||f$ r}ddlm}  |t        |            |d}~ww xY w)z
        Create a direct driver.

        Create a driver for direct Bolt server access that uses
        socket I/O and thread-based concurrency.
        r   BoltHandshakeErrorBoltSecurityErrorServiceUnavailableN)_exceptionsr   r   
BoltDriver_open
exceptionsr   r   )rg   targetr|   r   r   errorr   s          rF   ry   zGraphDatabase._bolt_driver  sL    	

	<##F5f55"$56 	<7$SZ0e;	<s     A?Ac                    ddl m}m} 	 t        j                  |fd|i|S # ||f$ r}ddlm}  |t        |            |d}~ww xY w)z
        Create a routing driver.

        Create a driver for routing-capable Neo4j service access
        that uses socket I/O and thread-based concurrency.
        r   r   rq   r   N)r   r   r   Neo4jDriverr   r   r   r   )rg   r   rq   r|   r   r   r   r   s           rF   r{   zGraphDatabase._neo4j_driver  s^    	

	<$$(7;A  #$56 	<7$SZ0e;	<s   " AAA):rh   r   rJ   _TAuth | AuthManagerrK   floatrL   zfloat | NonerM   intrN   r   rO   r   rP   z`t.Callable[[Address], t.Iterable[Address]] | t.Callable[[Address], t.Union[t.Iterable[Address]]]rQ   boolrR   r   rS   z4ClientCertificate | ClientCertificateProvider | NonerT   zssl.SSLContext | NonerU   r   rV   r   rW   $T_NotificationMinimumSeverity | NonerX   7t.Iterable[T_NotificationDisabledClassification] | NonerY   r   rZ   r   r[   r   r\   r   r]   r   r^   r   r_   r   r`   r   ra   
str | Nonerb   r   rc   r   rd   (BookmarkManager | BookmarkManager | NonereturnDriver)rh   r   rJ   r   r   r   )NNN)r   z"Bookmarks | t.Iterable[str] | Noner   z_TBmSupplier | Noner   z_TBmConsumer | Noner   r    rf   )rA   rB   rC   __doc__r   TYPE_CHECKINGclassmethodri   rd   ry   r{   rD   rE   rF   rI   rI   r   sp   :	
 *--036,/(+.1 !/2 14!"    '*0347 *-,//2#&!,/ a1	1	 '	1	
 &+1	 %11	 '*1	 !&1	 ',1	F1	 1	 #-1	" E#1	& /'1	( )1	* +1	. 5/1	6 H71	< H=1	B 5C1	F !%G1	H ).I1	J -2K1	P "'Q1	R %*S1	T (-U1	V !W1	X Y1	Z  *[1	^ 9_1	b c1	 
1	j 

 *.	k	k	 '	k	 k	 
k	Z  AE2626	h
=h
 0h
 0	h

 
h
 h
T < <& < <rE   rI   c                  >    e Zd ZdZdZdZd Zed        Ze	d        Z
y)_Direct	localhost  :c                    || _         y rf   _address)selfaddresss     rF   __init__z_Direct.__init__  s	    rE   c                    | j                   S rf   r   r   s    rF   r   z_Direct.address  s    }}rE   c                v    |s| j                   }t        j                  || j                  | j                        S )z,Parse a target string to produce an address.default_hostdefault_port)_default_targetr   parse_default_host_default_port)rg   r   s     rF   _parse_targetz_Direct._parse_target  s8     ((F}}****
 	
rE   N)rA   rB   rC   r   r   r   r   propertyr   r   r   rD   rE   rF   r   r     s>    MMO    
 
rE   r   c                  >    e Zd ZdZdZdZd Zed        Ze	d        Z
y)_Routingr   r   z: :17601 :17687c                    || _         y rf   _initial_addresses)r   initial_addressess     rF   r   z_Routing.__init__  s
    "3rE   c                    | j                   S rf   r   r   s    rF   r   z_Routing.initial_addresses  s    &&&rE   c                    dj                  |      }|s| j                  }t        j                  || j                  | j
                        S )z>Parse a sequence of target strings to produce an address list. r   )join_default_targetsr   
parse_listr   r   )rg   targetss     rF   _parse_targetsz_Routing._parse_targets  sH     ((7#**G!!****
 	
rE   N)rA   rB   rC   r   r   r   r   r   r   r   r   rD   rE   rF   r   r     s?    MM(4 ' ' 	
 	
rE   r   c                      e Zd ZU dZdZded<   dZd Zd"dZd Z	e
fd	Zd
 Zed#d       Zej                   r5dddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d$dZnd%dZd%dZd Zed        Zd&dZej.                  dej2                  dddddf	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d'd       Zej.                  dej2                  dddddf	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d(d       Zdej2                  ddedej:                  f	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d)dZed*d       Zej                   r8ddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d+dZnd&dZej                   r8ddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d,dZ nd-dZ d#dZ!ej                   r.	 	 	 	 	 	 	 	 	 	 	 	 	 d.	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d/dZ"n		 d0	 	 	 d1dZ"d#d Z#d-d!Z$y)2r   zf
    Base class for all driver types.

    Drivers are used as the primary access point to Neo4j.
    Nt.Any_poolFc                b    |J |J || _         || _        t        j                         | _        y rf   )r   _default_workspace_configrI   rd   _query_bookmark_managerr   pooldefault_workspace_configs      rF   r   zDriver.__init__  s:    '333
)A&'4'E'E'G$rE   c                    | S rf   rD   r   s    rF   	__enter__zDriver.__enter__  s    rE   c                $    | j                          y rf   )close)r   exc_type	exc_value	tracebacks       rF   __exit__zDriver.__exit__  s    

rE   c                .    | j                   s	 ||        y y rf   )_closed)r   _unclosed_resource_warns     rF   __del__zDriver.__del__  s     ||#D) rE   c                2    | j                   rt        d      y )NzDriver closed)r   r/   r   s    rF   _check_statezDriver._check_state  s    <<o.. rE   c                T    t        | j                  j                  j                        S )z=Indicate whether the driver was configured to use encryption.)r   r   pool_configrQ   r   s    rF   rQ   zDriver.encrypted	  s     DJJ**4455rE   .)r]   r\   ra   rb   rc   	bookmarksdefault_access_moderd   rJ   rW   rX   rY   r^   r_   r`   c                    y rf   rD   )r   r]   r\   ra   rb   rc   r   r   rd   rJ   rW   rX   rY   r^   r_   r`   s                   rF   sessionzDriver.session  s    : rE   c                    |j                  dd       | j                          d|v rt        dd       | j                  |      }| j	                  |      S )a  
            Create a session.

            See :ref:`session-construction-ref` for details.

            :param config: session configuration key-word arguments,
                see :ref:`session-configuration-ref` for available
                key-word arguments.

            :returns: new :class:`neo4j.Session` object

            :raises DriverError: if the driver has been closed.

            .. versionchanged:: 6.0

                * Raise :exc:`DriverError` if the driver has been closed.
                * Deprecated ``notifications_disabled_categories`` in favor of
                  ``notifications_disabled_classifications``.
            rZ   NrX   rk   r   rl   )popr   r   _read_session_config_sessionr   r|   session_configs      rF   r   zDriver.session1  sY    , JJ3T:2f< J !
 "66v>N==00rE   c                .    t        | j                  |      S rf   )r9   r   )r   r   s     rF   r   zDriver._sessionS  s    tzz>22rE   c                P    | j                  |      }t        | j                  |      S rf   )_prepare_session_configr   r   )r   config_kwargsr|   s      rF   r   zDriver._read_session_configV  s%    --m<T;;VDDrE   c                    t        |       |S rf   )rw   )rg   r   s     rF   r   zDriver._prepare_session_configZ  s    '6rE   c                    | j                   ry	 | j                  j                          d| _         y# t        j                  $ r	 d| _          w xY w)a  Shut down, closing any open connections in the pool.

        .. warning::

            While the driver object is concurrency-safe, ``close`` is *not*.
            Make sure you are not using the driver object or any resources
            spawned from it (such as sessions or transactions) while calling
            this method. Failing to do so results in unspecified behavior.
        NT)r   r   r   asyncioCancelledErrorr   s    rF   r   zDriver.close_  sM     <<	JJ  %% 	DL	s	   1 Ac	                     y rf   rD   
r   query_parameters_routing_	database_impersonated_user_bookmark_manager_auth_result_transformer_kwargss
             rF   execute_queryzDriver.execute_querys  s      rE   c	                     y rf   rD   r   s
             rF   r   zDriver.execute_query  s     rE   c	           
     8   | j                          |	D 
cg c]  }
|
dd dk7  s|
dd dk(  s|
 }}
|rt        d|d      t        |t              r;|j                  }|j
                  }|j                  } t        ||      t              }n|}t        }t        |xs i fi |	}|t        u r| j                  }|t        usJ | j                  ||||d      }| j                  |      }|5  |t        j                  k(  rt         }n(|t        j"                  k(  rt$        }nt        d|      |j&                  5  |j)                  |t*        j,                  ||||fi       cddd       cddd       S c c}
w # 1 sw Y   nxY w	 ddd       y# 1 sw Y   yxY w)	a"  
        Execute a query in a transaction function and return all results.

        This method is a handy wrapper for lower-level driver APIs like
        sessions, transactions, and transaction functions. It is intended
        for simple use cases where there is no need for managing all possible
        options.

        The internal usage of transaction functions provides a retry-mechanism
        for appropriate errors. Furthermore, this means that queries using
        ``CALL {} IN TRANSACTIONS`` or the older ``USING PERIODIC COMMIT``
        will not work (use :meth:`Session.run` for these).

        The method is roughly equivalent to::

            def execute_query(
                query_, parameters_, routing_, database_, impersonated_user_,
                bookmark_manager_, auth_, result_transformer_, **kwargs
            ):
                @unit_of_work(query_.metadata, query_.timeout)
                def work(tx):
                    result = tx.run(query_.text, parameters_, **kwargs)
                    return result_transformer_(result)

                with driver.session(
                    database=database_,
                    impersonated_user=impersonated_user_,
                    bookmark_manager=bookmark_manager_,
                    auth=auth_,
                ) as session:
                    if routing_ == RoutingControl.WRITE:
                        return session.execute_write(work)
                    elif routing_ == RoutingControl.READ:
                        return session.execute_read(work)

        Usage example::

            from typing import List

            import neo4j


            def example(driver: neo4j.Driver) -> List[str]:
                """Get the name of all 42 year-olds."""
                records, summary, keys = driver.execute_query(
                    "MATCH (p:Person {age: $age}) RETURN p.name",
                    {"age": 42},
                    routing_=neo4j.RoutingControl.READ,  # or just "r"
                    database_="neo4j",
                )
                assert keys == ["p.name"]  # not needed, just for illustration
                # log_summary(summary)  # log some metadata
                return [str(record["p.name"]) for record in records]
                # or: return [str(record[0]) for record in records]
                # or even: return list(map(lambda r: str(r[0]), records))

        Another example::

            import neo4j


            def example(driver: neo4j.Driver) -> int:
                """Call all young people "My dear" and get their count."""
                record = driver.execute_query(
                    "MATCH (p:Person) WHERE p.age <= $age "
                    "SET p.nickname = 'My dear' "
                    "RETURN count(*)",
                    # optional routing parameter, as write is default
                    # routing_=neo4j.RoutingControl.WRITE,  # or just "w",
                    database_="neo4j",
                    result_transformer_=neo4j.Result.single,
                    age=15,
                )
                assert record is not None  # for typechecking and illustration
                count = record[0]
                assert isinstance(count, int)
                return count

        :param query_:
            Cypher query to execute.
            Use a :class:`.Query` object to pass a query with additional
            transaction configuration.
        :type query_: typing.LiteralString | Query
        :param parameters_: parameters to use in the query
        :type parameters_: typing.Optional[typing.Dict[str, typing.Any]]
        :param routing_:
            Whether to route the query to a reader (follower/read replica) or
            a writer (leader) in the cluster. Default is to route to a writer.
        :type routing_: RoutingControl
        :param database_:
            Database to execute the query against.

            :data:`None` (default) uses the database configured on the server
            side.

            .. Note::
                It is recommended to always specify the database explicitly
                when possible. This allows the driver to work more efficiently,
                as it will not have to resolve the default database first.

            See also the Session config :ref:`database-ref`.
        :type database_: typing.Optional[str]
        :param impersonated_user_:
            Name of the user to impersonate.

            This means that all query will be executed in the security context
            of the impersonated user. For this, the user for which the
            :class:`Driver` has been created needs to have the appropriate
            permissions.

            See also the Session config :ref:`impersonated-user-ref`.
        :type impersonated_user_: typing.Optional[str]
        :param auth_:
            Authentication information to use for this query.

            By default, the driver configuration is used.

            See also the Session config :ref:`session-auth-ref`.
        :type auth_: typing.Tuple[typing.Any, typing.Any] | Auth | None
        :param result_transformer_:
            A function that gets passed the :class:`neo4j.Result` object
            resulting from the query and converts it to a different type. The
            result of the transformer function is returned by this method.

            .. warning::

                The transformer function must **not** return the
                :class:`neo4j.Result` itself.

            .. warning::

                N.B. the driver might retry the underlying transaction so the
                transformer might get invoked more than once (with different
                :class:`neo4j.Result` objects).
                Therefore, it needs to be idempotent (i.e., have the same
                effect, regardless if called once or many times).

            Example transformer that checks that exactly one record is in the
            result stream, then returns the record and the result summary::

                from typing import Tuple

                import neo4j


                def transformer(
                    result: neo4j.Result
                ) -> Tuple[neo4j.Record, neo4j.ResultSummary]:
                    record = result.single(strict=True)
                    summary = result.consume()
                    return record, summary

            Note that methods of :class:`neo4j.Result` that don't take
            mandatory arguments can be used directly as transformer functions.
            For example::

                import neo4j


                def example(driver: neo4j.Driver) -> neo4j.Record::
                    record = driver.execute_query(
                        "SOME QUERY",
                        result_transformer_=neo4j.Result.single
                    )


                # is equivalent to:


                def transformer(result: neo4j.Result) -> neo4j.Record:
                    return result.single()


                def example(driver: neo4j.Driver) -> neo4j.Record::
                    record = driver.execute_query(
                        "SOME QUERY",
                        result_transformer_=transformer
                    )

        :type result_transformer_:
            typing.Callable[[Result], typing.Union[T]]
        :param bookmark_manager_:
            Specify a bookmark manager to use.

            If present, the bookmark manager is used to keep the query causally
            consistent with all work executed using the same bookmark manager.

            Defaults to the driver's :attr:`.execute_query_bookmark_manager`.

            Pass :data:`None` to disable causal consistency.
        :type bookmark_manager_: BookmarkManager | BookmarkManager | None
        :param kwargs: additional keyword parameters. None of these can end
            with a single underscore. This is to avoid collisions with the
            keyword configuration parameters of this method. If you need to
            pass such a parameter, use the ``parameters_`` parameter instead.
            Parameters passed as kwargs take precedence over those passed in
            ``parameters_``.
        :type kwargs: typing.Any

        :returns: the result of the ``result_transformer_``
        :rtype: T

        :raises DriverError: if the driver has been closed.

        .. versionadded:: 5.5

        .. versionchanged:: 5.8

            * Added ``auth_`` parameter in preview.
            * Stabilized from experimental.

        .. versionchanged:: 5.14
            Stabilized ``auth_`` parameter from preview.

        .. versionchanged:: 5.15
            The ``query_`` parameter now also accepts a :class:`.Query` object
            instead of only :class:`str`.

        .. versionchanged:: 6.0
            Raise :exc:`DriverError` if the driver has been closed.
        _Nz:keyword parameters must not end with a single '_'. Found: z

You either misspelled an existing configuration parameter or tried to send a query parameter that is reserved. In the latter case, use the `parameters_` dictionary instead.)ra   rc   rd   rJ   zInvalid routing control value: )r   
ValueErrorrr   r   timeoutmetadatatextr   _workdict_defaultr   r   r   r   WRITEr*   READr"   _pipelined_begin_run_transactionr   DRIVER)r   r   r   r   r   r   r   r   r   r   kinvalid_kwargsr  r  	query_strwork
parametersr   r   access_modes                       rF   r   zDriver.execute_query  s   ` 	
2bSQrsVs]A
 
 (+ ,II  fe$nnGHI2<'259DID++6v6
( $ < < 00022%%7$5	
 --/ 	>///*^000) 5h\B  )) // ''
,?@ 	 	E
V  	 	 	s4   E5E5E5-AF<&E:"	F:F	?FFc                    | j                   S )aK  
        The driver's default query bookmark manager.

        This is the default :class:`.BookmarkManager` used by
        :meth:`.execute_query`. This can be used to causally chain
        :meth:`.execute_query` calls and sessions. Example::

            def example(driver: neo4j.Driver) -> None:
                driver.execute_query("<QUERY 1>")
                with driver.session(
                    bookmark_manager=driver.execute_query_bookmark_manager
                ) as session:
                    # every query inside this session will be causally chained
                    # (i.e., can read what was written by <QUERY 1>)
                    session.run("<QUERY 2>")
                # subsequent execute_query calls will be causally chained
                # (i.e., can read what was written by <QUERY 2>)
                driver.execute_query("<QUERY 3>")

        .. versionadded:: 5.5

        .. versionchanged:: 5.8

            * Renamed from ``query_bookmark_manager`` to
              ``execute_query_bookmark_manager``.
            * Stabilized from experimental.
        )r   r   s    rF   execute_query_bookmark_managerz%Driver.execute_query_bookmark_manager  s    : +++rE   )session_connection_timeoutr]   r\   ra   rb   rc   r   r   rd   rJ   rW   rX   rY   r^   r_   r`   c                    y rf   rD   r   r  r]   r\   ra   rb   rc   r   r   rd   rJ   rW   rX   rY   r^   r_   r`   s                    rF   verify_connectivityzDriver.verify_connectivity  s    < rE   c                    | j                          |rt        d       | j                  |      }| j                  |       y)a+  
            Verify that the driver can establish a connection to the server.

            This verifies if the driver can establish a reading connection to a
            remote server or a cluster. Some data will be exchanged.

            .. note::
                Even if this method raises an exception, the driver still needs
                to be closed via :meth:`close` to free up all resources.

            :param config: accepts the same configuration key-word arguments as
                :meth:`session`.

                .. warning::
                    Passing key-word arguments is a preview feature.
                    It might be changed or removed in any future version
                    without prior notice.

            :raises Exception: if the driver cannot connect to the remote.
                Use the exception to further understand the cause of the
                connectivity problem.
            :raises DriverError: if the driver has been closed.

            .. versionchanged:: 5.0
                The undocumented return value has been removed.
                If you need information about the remote server, use
                :meth:`get_server_info` instead.

            .. versionchanged:: 6.0
                Raise :exc:`DriverError` if the driver has been closed.
            zIPassing key-word arguments to verify_connectivity() is a preview feature.Nr   r   r   _get_server_infor   s      rF   r  zDriver.verify_connectivity  sA    @ ' "66v>N!!.1rE   c                    y rf   rD   r  s                    rF   get_server_infozDriver.get_server_info(  s    < rE   c                    | j                          |rt        d       | j                  |      }| j                  |      S )a  
            Get information about the connected Neo4j server.

            Try to establish a working read connection to the remote server or
            a member of a cluster and exchange some data. Then return the
            contacted server's information.

            In a cluster, there is no guarantee about which server will be
            contacted.

            .. note::
                Even if this method raises an exception, the driver still needs
                to be closed via :meth:`close` to free up all resources.

            :param config: accepts the same configuration key-word arguments as
                :meth:`session`.

                .. warning::
                    Passing key-word arguments is a preview feature.
                    It might be changed or removed in any future
                    version without prior notice.

            :raises Exception: if the driver cannot connect to the remote.
                Use the exception to further understand the cause of the
                connectivity problem.
            :raises DriverError: if the driver has been closed.

            .. versionadded:: 5.0

            .. versionchanged:: 6.0
                Raise :exc:`DriverError` if the driver has been closed.
            zEPassing key-word arguments to get_server_info() is a preview feature.r  r   s      rF   r"  zDriver.get_server_infoJ  sD    B ' "66v>N((88rE   c                   | j                          | j                  i       }| j                  |      5 }|j                  t               |j
                  sJ |j
                  j                  cddd       S # 1 sw Y   yxY w)a  
        Check if the server or cluster supports multi-databases.

        .. note::
            Feature support query based solely on the Bolt protocol version.
            The feature might still be disabled on the server side even if this
            function return :data:`True`. It just guarantees that the driver
            won't throw a :exc:`.ConfigurationError` when trying to use this
            driver feature.

        :returns: Returns true if the server or cluster the driver connects to
            supports multi-databases, otherwise false.

        :raises DriverError: if the driver has been closed.

        .. versionchanged:: 6.0
            Raise :exc:`DriverError` if the driver has been closed.
        N)r   r   r   _connectr"   _connectionsupports_multiple_databasesr   r   r   s      rF   supports_multi_dbzDriver.supports_multi_dbt  ss    & 	2226]]>* 	Cg[)&&&&&&BB	C 	C 	C   9A66A?c                     y rf   rD   )r   rJ   r  r]   r\   ra   rb   rc   r   r   rd   r^   r_   r`   s                 rF   verify_authenticationzDriver.verify_authentication  s    ( rE   c                X   | j                          |rt        d       d|vrd|d<   | j                  |      }t        |d|i      }| j	                  |      5 }	 |j                          	 ddd       y# t        $ r!}|j                  dv rY d}~ddd       y d}~ww xY w# 1 sw Y   yxY w)	a  
            Verify that the authentication information is valid.

            Like :meth:`.verify_connectivity`, but for checking authentication.

            Try to establish a working read connection to the remote server or
            a member of a cluster and exchange some data. In a cluster, there
            is no guarantee about which server will be contacted. If the data
            exchange is successful and the authentication information is valid,
            :data:`True` is returned. Otherwise, the error will be matched
            against a list of known authentication errors. If the error is on
            that list, :data:`False` is returned indicating that the
            authentication information is invalid. Otherwise, the error is
            re-raised.

            :param auth: authentication information to verify.
                Same as the session config :ref:`auth-ref`.
            :param config: accepts the same configuration key-word arguments as
                :meth:`session`.

                .. warning::
                    Passing key-word arguments (except ``auth``) is a preview
                    feature. It might be changed or removed in any future
                    version without prior notice.

            :raises Exception: if the driver cannot connect to the remote.
                Use the exception to further understand the cause of the
                connectivity problem.
            :raises DriverError: if the driver has been closed.

            .. versionadded:: 5.8

            .. versionchanged:: 5.14 Stabilized from experimental.

            .. versionchanged:: 6.0
                Raise :exc:`DriverError` if the driver has been closed.
            zYPassing key-word arguments except 'auth' to verify_authentication() is a preview feature.ra   systemrJ   >   "Neo.ClientError.Security.Forbidden%Neo.ClientError.Security.TokenExpired%Neo.ClientError.Security.Unauthorized+Neo.ClientError.Security.CredentialsExpiredNFT)r   r   r   r   r   _verify_authenticationr0   code)r   rJ   r|   r   r   excs         rF   r,  zDriver.verify_authentication  s    T D '%-z"!66v>N*>FD>JN~. '
224  " xx $   %   s6   B A33	B<B
B BBB  B)c                   | j                          | j                  i       }| j                  |      5 }|j                  t               |j
                  sJ |j
                  j                  cddd       S # 1 sw Y   yxY w)a   
        Check if the remote supports connection re-authentication.

        .. note::
            Feature support query based solely on the Bolt protocol version.
            The feature might still be disabled on the server side even if this
            function return :data:`True`. It just guarantees that the driver
            won't throw a :exc:`.ConfigurationError` when trying to use this
            driver feature.

        :returns: Returns true if the server or cluster the driver connects to
            supports re-authentication of existing connections, otherwise
            false.

        :raises DriverError: if the driver has been closed.

        .. versionadded:: 5.8

        .. versionchanged:: 6.0
            Raise :exc:`DriverError` if the driver has been closed.
        N)r   r   r   r%  r"   r&  supports_re_authr(  s      rF   supports_session_authzDriver.supports_session_auth  so    , 	2226]]>* 	8g[)&&&&&&77	8 	8 	8r*  c                p    | j                  |      5 }|j                         cd d d        S # 1 sw Y   y xY wrf   )r   r   r(  s      rF   r   zDriver._get_server_info  s1    ]]>* 	.g++-	. 	. 	.s   ,5)r   r   )r   r   ) r]   r   r\   r   ra   r   rb   r   rc   r   r   zBookmarks | Noner   r   rd   r   rJ   r   rW   r   rX   r   rY   r   r^   r   r_   r   r`   r   r   r9   )r   r9   )r   None)r   t.LiteralString | Queryr   dict[str, t.Any] | Noner   r=   r   r   r   r   r   r   r   r   r   z*t.Callable[[Result], t.Union[EagerResult]]r   r   r   r   )r   r;  r   r<  r   r=   r   r   r   r   r   r   r   r   r   !t.Callable[[Result], t.Union[_T]]r   r   r   rG   )r   r;  r   r<  r   r=   r   r   r   r   r   zJBookmarkManager | BookmarkManager | t.Literal[_DefaultEnum.default] | Noner   r   r   z$t.Callable[[Result], t.Union[t.Any]]r   r   r   r   )r   r    )"r  r   r]   r   r\   r   ra   r   rb   r   rc   r   r   "t.Iterable[str] | Bookmarks | Noner   r   rd   r   rJ   Auth | tuple[str, str]rW   r   rX   r   rY   r   r^   r   r_   r   r`   r   r   r:  )"r  r   r]   r   r\   r   ra   r   rb   r   rc   r   r   r>  r   r   rd   r   rJ   r?  rW   r   rX   r   rY   r   r^   r   r_   r   r`   r   r   r#   )r   r#   )N............)rJ   Auth | tuple[str, str] | Noner  r   r]   r   r\   r   ra   r   rb   r   rc   r   r   r>  r   r   rd   r   r^   r   r_   r   r`   r   r   r   rf   )rJ   r@  r   r   )%rA   rB   rC   r   r   __annotations__r   r   r   r   r   r   r   r   rQ   r   r   r   r   r   r   r   r   overloadr   r  r   r  r8   to_eager_resultr  r  r"  r)  r,  r8  r   rD   rE   rF   r   r     s.    E5 GH !7*/ 6 6 	
 5803#&!,/*-'*     *-,//29	 -2	 ).		
 !	 	  *	 (	 "%	 9	 	 5	& H'	, H-	4 "'5	6 %*7	8 (-9	: ;	B 	1D3E  ( ZZ 04%3%9%9 $)-  ' - #	
  ' 5 
  
 " ZZ 04%3%9%9 $)- AD' - #	
  ' 5  ?  
 $ 04%3%9%9 $)-  ""!c'c -c #	c
 c 'cc c
c" #c$ 
%cJ	 , ,< 	 144703#&!,/<?'* +.   ),,//2;	
 ).	 -2	 ).	 !	 	  *	 :	 "%	 9	  )!	$ 5%	* H+	0 H1	6 "'7	8 %*9	: (-;	< =	D'	2R 	 144703#&!,/<?'* +.   ),,//2;	
 ).	 -2	 ).	 !	 	  *	 :	 "%	 9	  )!	$ 5%	* H+	0 H1	6 "'7	8 %*9	: (-;	< =	D(	9TC4 	 37 144703#&!,/<?'* ),,//2'	/	
 ).	 -2	 ).	 !	 	  *	 :	 "%	 9	" "'#	$ %*%	& (-'	( )	4 37@	/@	 	@	D8:.rE   r   c                6    | j                  ||      } ||      S rf   )run)txrx   r  transformerress        rF   r
  r
    s     &&

#CsrE   c                  &    e Zd ZdZed        Zd Zy)r   a  
    :class:`.BoltDriver` is instantiated for ``bolt`` URIs.

    It addresses a single database machine. This may be a standalone server or
    could be a specific member of a cluster.

    Connections established by a :class:`.BoltDriver` are always made to
    the exact host and port detailed in the URI.

    This class is not supposed to be instantiated externally. Use
    :meth:`GraphDatabase.driver` instead.
    c                    ddl m} | j                  |      }t        j                  |t
        t              \  }}|j                  |||      } | ||      S )Nr1   )BoltPool)r   workspace_config)iorK  r   r   consume_chainr6   r   open)rg   r   r|   rK  r   r   r   r   s           rF   r   zBoltDriver._open$  s`     ##F+060D0DJ1
-- }}#5  

 4122rE   c                    t         j                  | |j                         t        j                  | ||       || _        y rf   )r   r   r   r   r   r   s      rF   r   zBoltDriver.__init__3  s/    t||,d$<=)A&rE   NrA   rB   rC   r   r   r   r   rD   rE   rF   r   r     s!     3 3BrE   r   c                  ,    e Zd ZdZeddd       Zd Zy)r   a  
    :class:`.Neo4jDriver` is instantiated for ``neo4j`` URIs.

    The routing behaviour works in tandem with Neo4j's `Causal Clustering
    <https://neo4j.com/docs/operations-manual/current/clustering/>`_
    feature by directing read and write behaviour to appropriate
    cluster members.

    This class is not supposed to be instantiated externally. Use
    :meth:`GraphDatabase.driver` instead.
    N)rq   c                   ddl m}  | j                  | }t        j                  |t
        t              \  }} |j                  ||||d} | ||      S )Nr1   )	Neo4jPool)rq   r   rL  )rM  rT  r   r   rN  r6   r   rO  )	rg   rq   r   r|   rT  	addressesr   r   r   s	            rF   r   zNeo4jDriver._openF  sb    !&C&&0	060D0DJ1
-- y~~+#5	
 4122rE   c                t    t         j                  | |j                  g       t        j                  | ||       y rf   )r   r   r   r   r   s      rF   r   zNeo4jDriver.__init__V  s)    $/d$<=rE   rQ  rD   rE   rF   r   r   9  s#    
 -1 3 3>rE   r   Frn   c          	     $   d}|D ]4  }| j                  |      }||D cg c]  }t        |d|       c}| |<   6 | j                  dd       }|*| j                  d      }||}nt        h ||      }|| d<   d}|D ]&  }| j                  |      }|t        |d|      | |<   ( | j                  d      }|h t        d vrt        d| d      |r7|t        rt        j                  | d<   y y |t        j                  k(  rd | d<   y y y c c}w )	N)rX   rY   valuerX   rY   )rW   rZ   rZ   z<Invalid value for configuration warn_notification_severity: zh. Should be None, a NotificationMinimumSeverity, or a string representing a NotificationMinimumSeverity.)	rt   getattrr   listr
   r  DEBUG_ENABLEDINFORMATIONOFF)	r   ro   list_config_keyskeyrX  edisabled_categoriesdisabled_classificationssingle_config_keyss	            rF   rw   rw   [  s      I!!#&BG!HQ'!Wa"8!HM#I
 (+++T &#0#4#44$
  $+':$'+A%A(@A($ % 	>? " @!!#&!(!?M#@
 :;E818488++0' 2+,
 	
 =/;; :;  1555:>M67 6 I "Is   D)
rF  r7   rx   zt.LiteralStringr  zdict[str, t.Any]rG  r=  r   rG   )]
__future__r   r   typesr    r   r   _addressingr   _apir   r	   r
   r   r   r   r   r   r   _confr   r   r   r   r   r   _debugr   r[  	_warningsr   r   r   r
  r   r   r   apir   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   auth_managementr+   r,   r-   r.   r   r/   r0   r2   rd   r3   r4   _TBmConsumerr5   _TBmSupplierr|   r6   r  r7   r8   r9   r   sslenumr:   r;   r<   r=   r?   r@   r  objectTypeVarrG   rI   r   r   r   r   r   rw   rD   rE   rF   <module>rt     s`  " #    !
 
 
  . 
 
     > 
   ?? t  ##H xHQYYt_|< |<~	
 
0
 
2g. g.T ! 3	
  B&  BF>(F >D DI 3?rE   