U Yzf_#Iã @sdZz\ddlZdZejejejdœZeedƒr:ejed<n ej ed<eedƒrZej rZdZ ndZ WndZdZ YnXddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZzddlZddlZWnek rêdZYnXdZdd lmZmZdd lmZd d lmZm Z m!Z!d d l"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(d dl)m*Z*m+Z+m,Z,m-Z-d dl.m/Z/d dl0m1Z1m2Z2d dl3m4Z4m5Z5m6Z6d dl7m8Z8m9Z9m:Z:m;Z;d dlZ>m?Z?m@Z@d dlAmBZBmCZCmDZDd dlEmFZFe jG Hd¡ddlImJZJddlKmLZLmMZMdZNdZOdZPdZQdZRdZSe Td¡ZUd ZVd ZWd!ZXd"ZYd#ZZd#Z[d$Z\eYeYeXeXe[eZeZe\d%œZ]e ^d&¡Z_d'd(„Z`Gd)d*„d*eaƒZbd+d,„ZcGd-d.„d.edƒZeGd/d0„d0ƒZfGd1d2„d2eaƒZgGd3d4„d4egƒZhGd5d6„d6e-jiƒZjGd7d8„d8eaƒZkGd9d:„d:eaƒZlGd;d<„d} z| ¡td  | ¡ƒ‚W5d} ~ XYnX|ržz| |¡tj|_Wn@ttjfk rœ} z| ¡td  | ¡ƒ‚W5d} ~ XYnX|röz| ||¡Wn@ttjfk rô} z| ¡td | ¡ƒ‚W5d} ~ XYnX|r| d t|d|ƒ¡¡z|j |j!|j"d|_!Wn2tj#k r`} ztt$| ƒƒ‚W5d} ~ XYnX|tjkrTd|_g} t%j&dkr¤|j"dksœ|j"dkr¤ddg} t' (|j"¡} |  )| dg| d¡d}g}| D]\}zt *|j! +¡|¡Wn4tj#k r"} z| ,t$| ƒ¡W5d} ~ XYn Xd}q2qÔ|sT| ¡td d |¡¡ƒ‚d|_-dS)axSet SSL parameters. Args: ssl_protos (list): SSL protocol to use. ssl_mode (str): SSL mode. ssl_ca (str): The certification authority certificate. ssl_crl (str): The certification revocation lists. ssl_cert (str): The certificate. ssl_key (str): The certificate key. ssl_ciphers (list): SSL ciphersuites to use. Raises: :class:`mysqlx.RuntimeError`: If Python installation has no SSL support. :class:`mysqlx.InterfaceError`: If the parameters are invalid. z&Python installation has no SSL supportNFT)Úreverserrr rrrzInvalid CA Certificate: {}zInvalid CRL: {}zInvalid Certificate/Key: {}ú:)Úserver_hostnameÚntÚ localhostz 127.0.0.1z$Unable to verify server identity: {}z, ).Ú SSL_AVAILABLErdrXÚsslÚcreate_default_contextrZVERIFY_IDENTITYÚcheck_hostnameÚREQUIREDÚ CERT_NONEÚ verify_modeÚsortÚTLS_V1_3_SUPPORTEDrYÚ TLS_VERSIONSÚ SSLContextÚoptionsÚ OP_NO_TLSv1_2Ú OP_NO_TLSv1_1Ú OP_NO_TLSv1Úload_verify_locationsÚ CERT_REQUIREDÚIOErrorÚSSLErrorrr`ÚVERIFY_CRL_CHECK_LEAFÚ verify_flagsÚload_cert_chainÚ set_ciphersr<r Ú wrap_socketrDrGÚCertificateErrorr:ÚosÚnamerLÚ gethostbyaddrÚextendÚmatch_hostnameÚ getpeercertr9rE)rIZ ssl_protosZssl_modeZssl_caZssl_crlZssl_certZssl_keyZ ssl_ciphersÚcontextZ tls_versionZ ssl_protocolraZ hostnamesÚaliasesZ match_foundZerrsÚhostnamer@r@rAÚset_sslís      ÿ ÿ        ÿÿ  ÿ   ÿzSocketStream.set_sslcCs|jS)zpVerifies if SSL is being used. Returns: bool: Returns `True` if SSL is being used. )rErHr@r@rAÚis_sslSszSocketStream.is_sslcCs|jS)zŒVerifies if socket connection is being used. Returns: bool: Returns `True` if socket connection is being used. )rFrHr@r@rAÚ is_socket[szSocketStream.is_socketcCs |jp |jS)zvVerifies if connection is secure. Returns: bool: Returns `True` if connection is secure. )rErFrHr@r@rAÚ is_securecszSocketStream.is_securecCs |jdk S)zrVerifies if connection is open. Returns: bool: Returns `True` if connection is open. N)rDrHr@r@rAÚis_openkszSocketStream.is_openN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rJÚ_CONNECT_TIMEOUTrQr]r^rdrgrrr‘r’r“r@r@r@rArCs   frCcstˆƒ‡fdd„ƒ}|S)zÆDecorator used to catch socket.error or RuntimeError. Raises: :class:`mysqlx.InterfaceError`: If `socket.Error` or `RuntimeError` is raised. c sBzˆ|f|ž|ŽWStjtfk r<| ¡tdƒ‚YnXdS)zWrapper function.zCannot connect to hostN)rLr_rXÚ disconnectr)rIÚargsr=©Úfuncr@rAÚwrapper{s z(catch_network_exception..wrapperr )rœrr@r›rAÚcatch_network_exceptiontsržc@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) ÚRouterz“Represents a set of connection parameters. Args: settings (dict): Dictionary with connection settings .. versionadded:: 8.0.20 cCs| |¡| dd¡|d<dS)NÚ availableT)ÚupdateÚget)rIZconnection_paramsr@r@rArJs zRouter.__init__cCs|dS)z’Verifies if the Router is available to open connections. Returns: bool: True if this Router is available else False. r r@rHr@r@rAr ‘szRouter.availablecCs d|d<dS)z:Sets this Router unavailable to open connections. Fr Nr@rHr@r@rAÚset_unavailable™szRouter.set_unavailablecCs d|kr|dS|d|dfS)z‘Verifies if the Router is available to open connections. Returns: tuple: host and port or socket information tuple. rLr4r5r@rHr@r@rAÚget_connection_paramsžszRouter.get_connection_paramsN)r”r•r–r—rJr r£r¤r@r@r@rArŸ†s rŸc@sHeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dS)Ú RouterManagerzÒManages the connection parameters of all the routers. Args: Routers (list): A list of Router objects. settings (dict): Dictionary with connection settings. .. versionadded:: 8.0.20 cCs0||_||_d|_d|_i|_g|_| ¡dS)NrT)Ú_routersÚ _settingsÚ_cur_priority_idxÚ _can_failoverÚ_routers_directoryÚrouters_priority_listÚ_ensure_priorities)rIÚroutersÚsettingsr@r@rArJ±szRouterManager.__init__cCsÜd}|jD]<}| dd¡}|dkr4|d7}d|d<q |dkr tddƒ‚q d|krbt|jƒkrpnn tdd ƒ‚|jjd d „d d |jD]L}|d}||j ¡krÂt|ƒg|j|<|j  |¡qŠ|j|  t|ƒ¡qŠdS)zuEnsure priorities. Raises: :class:`mysqlx.ProgrammingError`: If priorities are invalid. rÚpriorityNr édz(The priorities must be between 0 and 100i§z\You must either assign no priority to any of the routers or give a priority for every routeri cSs|dS)Nr¯r@©Úxr@r@rAÚÑrVz2RouterManager._ensure_priorities..T)r?rh) r¦r¢rrYrtrªÚkeysrŸr«r9)rIZpriority_countÚrouterr¯r@r@rAr¬»s*   ÿþ z RouterManager._ensure_prioritiescCs|j|}dd„|Dƒ}|S)z¡Get a list of the current available routers that shares the given priority. Returns: list: A list of the current available routers. cSsg|]}| ¡r|‘qSr@)r )Ú.0rµr@r@rAÚ ãsz8RouterManager._get_available_routers..©rª)rIr¯Ú router_listr@r@rAÚ_get_available_routersÜs z$RouterManager._get_available_routerscCsF| |¡}|sdSt|ƒdkr&|dSt|ƒd}t d|¡}||S)z{Get a random router from the group with the given priority. Returns: Router: A random router. Nr r)rºrYÚrandomÚrandint)rIr¯r¹ÚlastÚindexr@r@rAÚ_get_random_connection_paramsæs    z+RouterManager._get_random_connection_paramscCs|jS)zŒReturns the next connection parameters. Returns: bool: True if there is more server to failover to else False. )r©rHr@r@rAÚ can_failoveröszRouterManager.can_failovercCsÎ|jsBd|_|j ¡}|j dd¡|d<|j dd¡|d<t|ƒS|j|j}t|jƒ}d}|rÊ|  |¡}|dk s||j|kr¤|j|dkrÊt|  |¡ƒd krÊd|_qÊ|jd7_|j|kr\|j|j}q\|S) zvReturns the next connection parameters. Returns: Router: with the connection parameters. Fr4rlr5i$TNr é) r¦r©r§Úcopyr¢rŸr«r¨rYr¿rº)rIZrouter_settingsÚ cur_priorityZrouters_priority_lenÚsearchrµr@r@rAÚget_next_routerþs.    ÿÿ zRouterManager.get_next_routercCs|jS)z™Returns the directory containing all the routers managed. Returns: dict: Dictionary with priorities as connection settings. r¸rHr@r@rAÚget_routers_directory sz#RouterManager.get_routers_directoryN) r”r•r–r—rJr¬rºr¿rÀrÅrÆr@r@r@rAr¥©s ! "r¥c@s.eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zedd„ƒZedd„ƒZed d!„ƒZed"d#„ƒZed$d%„ƒZed?d'd(„ƒZed)d*„ƒZed+d,„ƒZed-d.„ƒZed/d0„ƒZed1d2„ƒZd3d4„Zd5d6„Zd7d8„Zd9d:„Z d;d<„Z!d=d>„Z"d&S)@Ú ConnectionzkConnection to a MySQL Server. Args: settings (dict): Dictionary with connection settings. cCsÄ||_tƒ|_d|_d|_| d¡|_| d¡|_| d¡|_d|_ | dg¡|_ d|kr‚|dr‚|j   | d¡| dd¡dœ¡t |j |ƒ|_ | dt¡|_|jd kr®d|_d |_g|_d |_dS) Nr6ÚpasswordÚschemar­r4r5)r4r5úconnect-timeoutrT)r®rCÚstreamÚprotocolÚ keep_openr¢Ú_userÚ _passwordZ_schemaÚ_active_resultr¦r9r¥Úrouter_managerr˜Ú_connect_timeoutÚ _stmt_counterÚ_prepared_stmt_idsÚ_prepared_stmt_supported)rIr®r@r@rArJ/s.    þÿ zConnection.__init__cCs|jdk r|j ¡d|_dS)zFetch active result.N)rÐÚ fetch_allrHr@r@rAÚfetch_active_resultLs  zConnection.fetch_active_resultcCs ||_dS)aSet active result. Args: `Result`: It can be :class:`mysqlx.Result`, :class:`mysqlx.BufferingResult`, :class:`mysqlx.RowResult`, :class:`mysqlx.SqlResult` or :class:`mysqlx.DocResult`. N)rЩrIÚresultr@r@rAÚset_active_resultRs zConnection.set_active_resultc Cs¨d}|j ¡rzÌ|j ¡}|j | ¡|j¡t|jƒ}t|jƒ}t ||ƒ|_ |j   ¡j }|rndd„|Dƒni}|  |¡d|jkrž|jd}|j j|d|j dd¡}|dkr¸dn | ||¡} | ¡|j  | ¡WdStjtfk r} z| }| ¡W5d} ~ XYqXq|dk r|t|tjƒsLt|d ƒr||jd kr|ts|t|jƒd krltd   |j¡ƒ‚td   |j¡ƒ‚t|jƒd kršt!d  |¡ƒ‚t!ddƒ‚dS)a Attempt to connect to the MySQL server. Raises: :class:`mysqlx.InterfaceError`: If fails to connect to the MySQL server. :class:`mysqlx.TimeoutError`: If connect timeout was exceeded. NcSsi|]}t|dƒ ¡|“qS©r‡)rÚlower)r¶Úcapr@r@rAÚ qsÿ z&Connection.connect..Ú attributes©Zsession_connect_attrsÚ compressionÚ preferredÚdisabledÚerrno)é ésr zLConnection attempt to the server was aborted. Timeout of {0} ms was exceededzdAll server connection attempts were aborted. Timeout of {0} ms was exceeded for each selected serverzCannot connect to host: {0}z,Unable to connect to any of the target hostsi¡)"rÑrÀrÅrËrQr¤rÒr"r#r!rÌZget_capabilitesZ capabilitiesÚ_set_tls_capabilitiesr®Úset_capabilitiesr¢Ú_set_compression_capabilitiesÚ _authenticateZset_compressionrLr_rXr£Ú isinstanceÚtimeoutÚhasattrrärrYr¦rr`r) rIr_rµÚreaderÚwriterZ caps_dataÚcapsÚ conn_attrsráÚ algorithmrar@r@rArQ]sh    ÿ    ýþý   ÿ  ÿ   ÿþþþþþzConnection.connectc CsP|j d¡tjkrdS|j ¡r:|j d¡r6t d¡dSd|krR| ¡t dƒ‚d}t   ¡dkr¦t ƒ\}}}zd|koˆ|  d ¡d d k}Wntk r¤d}YnXtjd krÄ|sÄ| ¡td ƒ‚|jjdd|j |j dd¡|j dtj¡|j d¡|j d¡|j d¡|j d¡|j d¡¡d|jkrL|jd}|jj|ddS)aªSets the TLS capabilities. Args: caps (dict): Dictionary with the server capabilities. Raises: :class:`mysqlx.OperationalError`: If SSL is not enabled at the server. :class:`mysqlx.RuntimeError`: If support for SSL is not available in Python. .. versionadded:: 8.0.21 zssl-modeNz(SSL not required when using Unix socket.ÚtlszSSL not enabled at serverFÚLinuxz Oracle LinuxÚ.rÚ7)rÁéé z.Úarrayr?cSsg|]}|jjj d¡‘qS)r )rr rr r r@r@rAr·ósÿròZ lz4_messageZdeflate_streamzFCompression requested but the compression algorithm negotiation failed)rá)r¢rrùrúrëÚdictrrrr r?r$rrÌrè) rIrðráZcompression_dataÚmsgZcompression_dictrZserver_algorithmsròr@r@rAréÏs:    þþ    z(Connection._set_compression_capabilitiescCs´|j d¡}|rL|tjkr$| ¡q°|tjkr8| ¡q°|tjkr°| ¡nd|j   ¡r`| ¡nPz | ¡Wnt k r€YnXdSz | ¡Wnt k r®t dƒ‚YnXdS)z#Authenticate with the MySQL server.ÚauthNzmAuthentication failed using MYSQL41 and SHA256_MEMORY, check username and password or try a secure connection) r®r¢rZPLAINÚ_authenticate_plainZ SHA256_MEMORYÚ_authenticate_sha256_memoryZMYSQL41Ú_authenticate_mysql41rËr’r)rIrr@r@rArê s&           zConnection._authenticatecCsHt|j|jƒ}|j | ¡¡|j ¡}|j | |¡¡|j  ¡dS)z=Authenticate with the MySQL server using `MySQL41AuthPlugin`.N) r rÎrÏrÌÚsend_auth_startÚ auth_nameÚread_auth_continueÚsend_auth_continueÚ auth_dataÚ read_auth_ok©rIÚpluginÚ extra_datar@r@rAr's  z Connection._authenticate_mysql41cCsF|j ¡stdƒ‚t|j|jƒ}|jj| ¡|  ¡d|j  ¡dS)z;Authenticate with the MySQL server using `PlainAuthPlugin`.z>PLAIN authentication is not allowed via unencrypted connection)rN) rËr’rrrÎrÏrÌrrrr)rIrr@r@rAr/s  ÿzConnection._authenticate_plaincCsHt|j|jƒ}|j | ¡¡|j ¡}|j | |¡¡|j  ¡dS)zBAuthenticate with the MySQL server using `Sha256MemoryAuthPlugin`.N) rrÎrÏrÌrrrrrrrr@r@rAr9s  z&Connection._authenticate_sha256_memorycCs,|jr(|j |j¡|j |j¡d|_dS)zrDeallocates statement. Args: statement (Statement): A `Statement` based type object. FN)ÚpreparedrÌÚsend_prepare_deallocateÚstmt_idrÔÚremove)rIÚ statementr@r@rAÚ_deallocate_statementAsz Connection._deallocate_statementcCsRz| ¡|j |||¡Wntk r8d|_YdSX|j |j¡d|_dS)zåPrepares a statement. Args: msg_type (str): Message ID string. msg (mysqlx.protobuf.Message): MySQL X Protobuf Message. statement (Statement): A `Statement` based type object. FNT) r×rÌZsend_prepare_preparerrÕrÔr9rr©rIÚmsg_typerr!r@r@rAÚ_prepare_statementLszConnection._prepare_statementcCs\|js|j |||¡dS|jrr| |¡| |||¡|jsR|j |||¡dS|j |||¡d|_| ¡nÞ|jr|j s|j |||¡nÀ|j rÆ|j sÆ| |¡|j |||¡d|_ | ¡nŠ|j s|j s|jsê| |||¡|js|j |||¡dS|j |||¡n8|j rP|j rP| |¡|j |||¡d|_ | ¡|  ¡dS)zùExecutes the prepared statement pipeline. Args: msg_type (str): Message ID string. msg (mysqlx.protobuf.Message): MySQL X Protobuf Message. statement (Statement): A `Statement` based type object. NF) rÕrÌÚsend_msg_without_psZdeallocate_prepare_executer"r%Zsend_prepare_executeZreset_exec_counterrÚchangedZrepeatedZincrement_exec_counterr#r@r@rAÚ_execute_prepared_pipeline]s@        z%Connection._execute_prepared_pipelinecCs€|j}|jdkrtdƒ‚t|tƒs*tdƒ‚tsVt|tƒrV|j dt t |dƒƒ¡\}}n|j d|¡\}}|j  |||¡t |ƒS)zóExecute a SQL statement. Args: sql (str): The SQL statement. Raises: :class:`mysqlx.ProgrammingError`: If the SQL statement is not a valid string. NrUz'The SQL statement is not a valid stringÚsqlr ) r)rÌrrërrrrÚbuild_execute_statementÚbytesÚ bytearrayr&r')rIr!r)r$rr@r@rAÚsend_sqls    ÿ ÿzConnection.send_sqlcCsN|jdkrtdƒ‚|j |¡\}}|j ||¡d}t|tƒrD|j}t||ƒS)a Send an insert statement. Args: statement (`Statement`): It can be :class:`mysqlx.InsertStatement` or :class:`mysqlx.AddStatement`. Returns: :class:`mysqlx.Result`: A result object. NrU)rÌrZ build_insertÚsend_msgrër*Úidsr%)rIr!r$rr/r@r@rAÚ send_insert¨s  zConnection.send_insertcCs6|j |¡\}}| |||¡| ¡r.t|ƒSt|ƒS)aDSend an find statement. Args: statement (`Statement`): It can be :class:`mysqlx.SelectStatement` or :class:`mysqlx.FindStatement`. Returns: `Result`: It can be class:`mysqlx.DocResult` or :class:`mysqlx.RowResult`. )rÌZ build_findr(Z is_doc_basedr(r&©rIr!r$rr@r@rAÚ send_find¼s zConnection.send_findcCs&|j |¡\}}| |||¡t|ƒS)aSend an delete statement. Args: statement (`Statement`): It can be :class:`mysqlx.RemoveStatement` or :class:`mysqlx.DeleteStatement`. Returns: :class:`mysqlx.Result`: The result object. )rÌÚ build_deleter(r%r1r@r@rAÚ send_deleteÌs zConnection.send_deletecCs&|j |¡\}}| |||¡t|ƒS)aSend an delete statement. Args: statement (`Statement`): It can be :class:`mysqlx.ModifyStatement` or :class:`mysqlx.UpdateStatement`. Returns: :class:`mysqlx.Result`: The result object. )rÌZ build_updater(r%r1r@r@rAÚ send_updateÛs zConnection.send_updateNcCsLz,|j |||¡\}}|j ||¡t|ƒWStk rF|rB‚YnXdS)a‹Execute a non query command. Args: namespace (str): The namespace. cmd (str): The command. raise_on_fail (bool): `True` to raise on fail. fields (Optional[dict]): The message fields. Raises: :class:`mysqlx.OperationalError`: On errors. Returns: :class:`mysqlx.Result`: The result object. N)rÌr*r.r%r)rIÚ namespaceÚcmdZ raise_on_failÚfieldsr$rr@r@rAÚexecute_nonqueryêsÿ zConnection.execute_nonquerycCsN|j d|¡\}}|j ||¡t|ƒ}| ¡|jdkrBtdƒ‚|ddS)zèExecute a SQL scalar. Args: sql (str): The SQL statement. Raises: :class:`mysqlx.InterfaceError`: If no data found. Returns: :class:`mysqlx.Result`: The result. r)rz No data found)rÌr*r.r&rÖrZr)rIr)r$rrÙr@r@rAÚexecute_sql_scalars  zConnection.execute_sql_scalarcCs*|j d||¡\}}|j ||¡t|ƒS)zÎReturns the row result. Args: cmd (str): The command. fields (dict): The message fields. Returns: :class:`mysqlx.RowResult`: The result object. r3)rÌr*r.r&)rIr7r8r$rr@r@rAÚget_row_results ÿzConnection.get_row_resultcCs |j |¡S)zdRead row. Args: result (:class:`mysqlx.RowResult`): The result object. )rÌÚread_rowrØr@r@rAr<(szConnection.read_rowcCs|j |¡dS)zeClose result. Args: result (:class:`mysqlx.Result`): The result object. N)rÌÚ close_resultrØr@r@rAr=1szConnection.close_resultcCs |j |¡S)zlGet column metadata. Args: result (:class:`mysqlx.Result`): The result object. )rÌÚget_column_metadatarØr@r@rAr>:szConnection.get_column_metadatacCs|jd7_|jS)z|Returns the next statement ID. Returns: int: A statement ID. .. versionadded:: 8.0.16 r )rÓrHr@r@rAÚget_next_statement_idCsz Connection.get_next_statement_idcCs |j ¡S)zgCheck if connection is open. Returns: bool: `True` if connection is open. )rËr“rHr@r@rAr“NszConnection.is_opencCs| ¡s dS|j ¡dS)zDisconnect from server.N)r“rËrdrHr@r@rAr™VszConnection.disconnectc Csž| ¡s dSz€zD| ¡|jr<|jD]}|j |¡q$d|_|j  ¡|j  ¡Wn6t t fk rˆ}zt  d |¡¡W5d}~XYnXW5|j ¡XdS)z*Close a sucessfully authenticated session.NrzGWarning: An error occurred while attempting to close the connection: {})r“rËrdr×rÕrÔrÌrrÓZ send_closeÚread_okrrrùrúr`)rIrrar@r@rAÚ close_session\s  ÿzConnection.close_sessionc Csp| ¡s dS|jdk r |j ¡z|j |j¡|_Wn6ttfk rj}zt  d  |¡¡W5d}~XYnXdS)z*Reset a sucessfully authenticated session.NzDWarning: An error occurred while attempting to reset the session: {}) r“rÐrÖrÌZ send_resetrÍrrrùrúr`)rIrar@r@rAÚ reset_sessionts  ÿzConnection.reset_sessioncCsB| ¡s dS|jdk r |j ¡|j ¡|j ¡|j ¡dS)z€Announce to the server that the client wants to close the connection. Discards any session state of the server. N)r“rÐrÖrÌZsend_connection_closer@rËrdrHr@r@rArû€s    zConnection.close_connection)N)#r”r•r–r—rJr×rÚrQrçrérêrrrr"r%r(ržr-r0r2r4r5r9r:r;r<r=r>r?r“r™rArBrûr@r@r@rArÇ)sT >4;  2             rÇcsLeZdZdZ‡fdd„Z‡fdd„Zdd„Zdd „Zd d „Zd d „Z ‡Z S)ÚPooledConnectionaClass to hold :class:`Connection` instances in a pool. PooledConnection is used by :class:`ConnectionPool` to facilitate the connection to return to the pool once is not required, more specifically once the close_session() method is invoked. It works like a normal Connection except for methods like close() and sql(). The close_session() method will add the connection back to the pool rather than disconnecting from the MySQL server. The sql() method is used to execute sql statements. Args: pool (ConnectionPool): The pool where this connection must return. .. versionadded:: 8.0.13 csFt|tƒstdƒ‚tt|ƒ |j¡||_|jd|_|jd|_ dS)Nz&pool should be a ConnectionPool objectr4r5) rëÚConnectionPoolrRÚsuperrCrJÚ cnx_configÚpoolr4r5)rIrG©Ú __class__r@rArJŸs   zPooledConnection.__init__cstt|ƒ ¡dS)zGCloses the connection. This method closes the socket. N)rErCrArHrHr@rArû§sz!PooledConnection.close_connectioncCs|j |¡dS)a“Do not close, but add connection back to pool. The close_session() method does not close the connection with the MySQL server. The connection is added back to the pool so it can be reused. When the pool is configured to reset the session, the session state will be cleared by re-authenticating the user once the connection is get from the pool. N)rGÚadd_connectionrHr@r@rArA®s zPooledConnection.close_sessioncCs |jdk r|j ¡| ¡dS)z#Reconnect this connection. N)rÐrÖrêrHr@r@rAÚ reconnect»s  zPooledConnection.reconnectcCs | ¡dS)zQReset the connection. Resets the connection by re-authenticate. N)rKrHr@r@rAÚresetÂszPooledConnection.resetcCs t||ƒS©aCreates a :class:`mysqlx.SqlStatement` object to allow running the SQL statement on the target MySQL Server. Args: sql (string): The SQL statement to be executed. Returns: mysqlx.SqlStatement: SqlStatement object. )r)©rIr)r@r@rAr)És zPooledConnection.sql) r”r•r–r—rJrûrArKrLr)Ú __classcell__r@r@rHrArCs   rCc@s‚eZdZdZdd„Zdd„Zedd„ƒZdd d „Zdd d „Z d d„Z dd„Z dd„Z dd„Z d dd„Zdd„Zdd„Zdd„ZdS)!rDaµThis class represents a pool of connections. Initializes the Pool with the given name and settings. Args: name (str): The name of the pool, used to track a single pool per combination of host and user. **kwargs: max_size (int): The maximun number of connections to hold in the pool. reset_session (bool): If the connection should be reseted when is taken from the pool. max_idle_time (int): The maximum number of milliseconds to allow a connection to be idle in the queue before being closed. Zero value means infinite. queue_timeout (int): The maximum number of milliseconds a request will wait for a connection to become available. A zero value means infinite. priority (int): The router priority, to choose this pool over other with lower priority. Raises: :class:`mysqlx.PoolError` on errors. .. versionadded:: 8.0.13 cKs¦| |¡d|_g|_d|_d|_t ¡|_| dd¡|_ t j   ||j ¡| dd¡|_ | dd¡|_||_| dd¡|_| dd¡|_||_|d |_|d |_dS) NrTÚmax_sizeérBÚ max_idle_timeÚ queue_timeoutr¯r4r5)Ú_set_pool_nameZ_open_sessionsÚ_connections_opennedÚ _availableÚ_timeoutrÚnowÚ_timeout_stampr¢Ú pool_max_sizerÚQueuerJrBrRr®rSr¯rFr4r5)rIr‡r=r@r@rArJòs    zConnectionPool.__init__cCs<t |¡rtd |¡ƒ‚t|ƒtkr2td |¡ƒ‚||_dS)aƒSet the name of the pool. This method checks the validity and sets the name of the pool. Args: pool_name (str): The pool name. Raises: AttributeError: If the pool_name contains illegal characters ([^a-zA-Z0-9._\-*$#]) or is longer than connection._CNX_POOL_MAX_NAME_SIZE. z+Pool name '{0}' contains illegal characterszPool name '{0}' is too longN)Ú_CNX_POOL_NAME_REGEXrÄrRr`rYÚ_CNX_POOL_MAX_NAME_SIZEr‡)rIÚ pool_namer@r@rArTs ÿ ÿzConnectionPool._set_pool_namecCs t|jƒS)zMReturns the number of open connections that can return to this pool. )rYrUrHr@r@rAÚopen_connectionsszConnectionPool.open_connectionsNcCs|j |¡dS)zwRemoves a connection from this pool. Args: cnx (PooledConnection): The connection object. N)rUr ©rIÚcnxr@r@rAÚremove_connection sz ConnectionPool.remove_connectioncCs®|jstdƒ‚| ¡rtdƒ‚|sŽt|ƒ}| d¡ ¡ ¡dd}tdd„| d¡d d ¡Dƒƒd kr€| d   |j ¡¡ ¡|j   |¡nt |tƒs td ƒ‚| |¡d S)a=Adds a connection to this pool. This method instantiates a Connection using the configuration passed when initializing the ConnectionPool instance or using the set_config() method. If cnx is a Connection instance, it will be added to the queue. Args: cnx (PooledConnection): The connection object. Raises: PoolError: If no configuration is set, if no more connection can be added (maximum reached) or if the connection can not be instantiated. z&Connection configuration not availableú'Failed adding connection; queue is fullúshow variables like "version"rr cSsg|] }t|ƒ‘qSr@©Úint©r¶Únr@r@rAr·Csz1ConnectionPool.add_connection..ú-rõ©éré úset mysqlx_wait_timeout = {}ú2Connection instance not subclass of PooledSession.N)rFrÚfullrCr)ÚexecuterÖÚtuplerþr`rRrUr9rëÚqueue_connection)rIraÚverr@r@rArJ(s.ÿÿ ÿÿ  ÿzConnectionPool.add_connectioncCsVt|tƒstdƒ‚|jr | ¡z|j|ddWntjk rPtdƒYnXdS)aGPut connection back in the queue: This method is putting a connection back in the queue. It will not acquire a lock as the methods using _queue_connection() will have it set. Args: PooledConnection: The connection object. Raises: PoolError: On errors. rnF)ÚblockrcN)rërCrrBÚputrÚFullr`r@r@rArrOs ÿzConnectionPool.queue_connectioncCs|j |¡dS)zNTracks connection in order of close it when client.close() is invoke. N)rUr9)rIÚ connectionr@r@rAÚtrack_connectionhszConnectionPool.track_connectioncCs|jSrerÛrHr@r@rAÚ__str__mszConnectionPool.__str__cCs|jS)z¸Returns if this pool is available for pool connectinos from it. Returns: bool: True if this pool is available else False. .. versionadded:: 8.0.20 )rVrHr@r@rAr pszConnectionPool.availableéÿÿÿÿcCsd|_t ¡|_||_dS)zhSets this pool unavailable for a period of time (in seconds). .. versionadded:: 8.0.20 FN)rVrrXrYrW)rIZtime_outr@r@rAr£ys zConnectionPool.set_unavailablecCsd|_t ¡|_dS)zaSets this pool available for pool connectinos from it. .. versionadded:: 8.0.20 TN)rVrrXrYrHr@r@rAÚ set_available‚szConnectionPool.set_availablecCs |j|jfS)zÏReturnds the penalized time (timeout) and the time at the penalty. Returns: tuple: penalty seconds (int), timestamp at penalty (datetime object) .. versionadded:: 8.0.20 )rWrYrHr@r@rAÚget_timeout_stampŠsz ConnectionPool.get_timeout_stampcCs|jD] }| ¡qdS)z#Empty this ConnectionPool. N)rUrûr`r@r@rArd“s zConnectionPool.close)N)N)rz)r”r•r–r—rJrTÚpropertyr_rbrJrrrxryr r£r{r|rdr@r@r@rArDÖs   '  rDc@s|eZdZdZdZiZdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z ddd„Zddd„Zdd„Zdd„ZdS)Ú PoolsManagerz–Manages a pool of connections for a host or hosts in routers. This class handles all the pools of Connections. .. versionadded:: 8.0.13 NcCs"tjdkrt |¡t_it_tjSre)r~Ú_PoolsManager__instanceÚobjectÚ__new__Ú_PoolsManager__pools)Úclsr@r@rAr¤s  zPoolsManager.__new__cCs,|j |g¡}|D]}|j|krdSqdS)zþVerifies if a pool exists with the given name. Args: client_id (str): The client id. pool_name (str): The name of the pool. Returns: bool: Returns `True` if the pool exists otherwise `False`. TF)r‚r¢r‡)rIr7r^ÚpoolsrGr@r@rAÚ _pool_existsªs  zPoolsManager._pool_existscCs^g}g}| |¡}|D]\}}| |¡q|j | dd¡g¡D]}|j|kr@| |¡q@|S)záRetrieves a list of pools that shares the given settings. Args: settings (dict): the configuration of the pool. Returns: list: A list of pools that shares the given settings. r7úNo id)Ú_get_connections_settingsr9r‚r¢r‡)rIr®Zavailable_poolsZ pool_namesÚconnections_settingsÚ router_namer8rGr@r@rAÚ _get_poolsºs      zPoolsManager._get_poolscCsÄ| ¡}| dg¡}g}d|kr*| d¡d|krVd|krV| dd|d|ddœ¡|jdd„d |D]T}| ¡}|d|d<|d|d<|d |d <| d d¡|d <| tf|Ž|f¡qj|S) aHGenerates a list of separated connection settings for each host. Gets a list of connection settings for each host or router found in the given settings. Args: settings (dict): The configuration for the connections. Returns: list: A list of connections settings r­r4r5r°r)r¯Úweightr4r5cSs|d| dd¡ fS)Nr¯r‹r)r¢r±r@r@rAr³èrVz8PoolsManager._get_connections_settings..)r?r¯r‹)rÂr¢Úpopr9rtrB)rIr®Z pool_settingsr­rˆrµZconnection_settingsr@r@rAr‡Ñs0   ý   ÿÿz&PoolsManager._get_connections_settingscCs€| |¡}| dd¡|jkr.g|j| dd¡<|D]H\}}| | dd¡|¡rRq2q2|j | dd¡g¡}| t|f|Ž¡q2dS)a#Creates a `ConnectionPool` instance to hold the connections. Creates a `ConnectionPool` instance to hold the connections only if no other pool exists with the same configuration. Args: cnx_settings (dict): The configuration for the connections. r7r†N)r‡r¢r‚r…r9rD)rIÚ cnx_settingsrˆr‰r®rGr@r@rAÚ create_poolôs  ÿÿzPoolsManager.create_poolcCs<|sdSt|ƒdkr|dSt|ƒd}t d|¡}||S)zGet a random router from the group with the given priority. Returns: Router: a random router. .. versionadded:: 8.0.20 Nr r)rYr»r¼)rIZ pool_listr½r¾r@r@rAÚ_get_random_pool s   zPoolsManager._get_random_poolcCsZg}d}|t|ƒkrV||j}||krB|| ¡rB| ||¡n ||krLqV|d7}q|S)Nr )rYr¯r r9)rIr„r¾rÃZsublistZ next_priorityr@r@rAÚ get_sublists   zPoolsManager.get_sublistcCsbd}|D]"}| ¡r"||jkr"q,|d7}qg}|sX|t|ƒkrX| |||¡}|d7}q0| |¡S)Nrr )r r¯rYrr)rIr„rÃr¾rGZsubpoolr@r@rAÚ_get_next_pool*s  zPoolsManager._get_next_poolcCs<|dkr|r|djS|D]}|j|kr|j}|SqdS)Nr)r¯)rIr„rÃZt_poolr@r@rAÚ_get_next_priority6s    zPoolsManager._get_next_prioritycCsT| |¡}|D]@}| ¡rq| ¡\}}|r0|}t ¡|t|dkr| ¡qdS)N)Úseconds)rŠr r|rrXr r{)rIr®Zreviver„rGrìZ timeout_stampr@r@rAÚ_check_unavailable_poolsAs  z%PoolsManager._check_unavailable_poolsc Cs | |¡}| dd¡}g}|dkr.| ||¡}||d<| |¡| ||¡}|dk rz®| ¡dkrÄt ¡Hz|jd|jd}Wnt j k r¦t dƒ‚YnXz.|j s¸|  ¡| d¡ ¡ ¡dd}Wn’ttjtfk rhz0z | ¡Wnttjtfk rYnXW5| |¡X| ¡dkr¬z|jd|jd}Wnt j k rhYn@Xz0z | ¡Wnttjtfk r–YnXW5| |¡Xq.z\z8t|ƒ}| |¡| ¡| d¡ ¡ ¡dd}Wnttjtfk rYnXW5| ¡dkrbz&|jd|jd}| ¡| |¡Wnttjtfk r\YnXq XYnXtd d „| d ¡d d ¡Dƒƒd kr¨| d |j¡¡ ¡|W5QR£WSQRXn@|j|jkrJt|ƒ}| |¡| ¡| d¡ ¡ ¡dd}tdd „| d ¡d d ¡Dƒƒd krD| d |j¡¡ ¡|WSt ¡¬z„|jd|jd}|  ¡| d¡ ¡ ¡dd}tdd „| d ¡d d ¡Dƒƒd krÆ| d |j¡¡ ¡|WW5QR£WSt j k røt dƒ‚YnXW5QRXWqLtt t fk r}zØ| !d ||¡¡t"|t ƒrJ| #d¡n@d} t$D]} | |j%krRt$| } qR| r€| #| ¡n | #d¡| |¡| ||¡}|dkrì| ||¡}||d<| ||¡}|dkrìd &|¡} t d | ¡ƒ‚WY¢qLW5d}~XYqLXqLdS)ažGet a connection from the pool. This method returns an `PooledConnection` instance which has a reference to the pool that created it, and can be used as a normal Connection. When the MySQL connection is not connected, a reconnect is attempted. Raises: :class:`PoolError`: On errors. Returns: PooledConnection: A pooled connection object. rÃNrT)rtrìz)Failed getting connection; pool exhaustedrdr cSsg|] }t|ƒ‘qSr@rergr@r@rAr·¤sz/PoolsManager.get_connection..rirõrjrmcSsg|] }t|ƒ‘qSr@rergr@r@rAr·±scSsg|] }t|ƒ‘qSr@rergr@r@rAr·Àszpool max size has been reachedzpool: {} error: {}rÁi †z z6Unable to connect to any of the target hosts: [ {} ])'rŠr¢r’r”r‘ÚqsizeÚ threadingÚRLockrSrÚEmptyrrÍrLr)rprÖrXrLr_rrbrûrCrxrQrqrþr`rRr_rZrr9rër£Ú_TIMEOUT_PENALTIESrr<) rIr®r„rÃZ error_listrGrarsraZpenaltyZtimeout_penaltyrr@r@rAÚget_connectionLs       ÿ ÿ ÿÿ    ÿ    ÿÿ ÿÿÿÿ  ÿÿÿÿÿ  ÿÿÿÿþÿ              ÿzPoolsManager.get_connectioncCsX| |¡}|D]@}| ¡| dd¡dk r|j | d¡¡}||kr| |¡qt|ƒS)zjCloses the connections in the pools Returns: int: The number of closed pools r7N)rŠrdr¢r‚r rY)rIrr„rGZ client_poolsr@r@rAÚ close_poolès  zPoolsManager.close_pool)N)N)r”r•r–r—rr‚rr…rŠr‡rŽrrr‘r’r”ršr›r@r@r@rAr~šs #  r~c@sÌeZdZdZdd„Zdd„Zdd„Zdd „Zed d „ƒZ e j d d „ƒZ d d„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd.d$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd#S)/ÚSessionaWEnables interaction with a X Protocol enabled MySQL Product. The functionality includes: - Accessing available schemas. - Schema management operations. - Enabling/disabling warning generation. - Retrieval of connection information. Args: settings (dict): Connection data used to connect to the database. c Csº| dtj¡|_||_| d¡r¶| d¡r¶ts6tdƒ‚ztj |dd¡}Wn*tj j k rvtd  |d¡ƒ‚YnXg|jd<|D].}|jd  |j jdd |j|j|jd œ¡q†d |jksÎ|jd d krài|jd <| ¡d|kr$|dr$tƒ |¡tƒ |¡|_|jdkr:tdƒ‚nt|jƒ|_|j ¡|j d¡}|r¶z| d  t|ƒ¡¡ ¡WnLtk r´}z,|jdkrŽ|jnd  |¡}t||jƒ‚W5d}~XYnXdS)Nzuse-purer4zdns-srvztMySQL host configuration requested DNS SRV. This requires the Python dnspython module. Please refer to documentationZSRVz$Unable to locate any hosts for '{0}'r­T)Zomit_final_dot)r4r5r¯r‹úconnection-attributesFrßÚpoolingz+Connection could not be retrieved from poolrÉzUSE {}iú#Default schema '{}' does not exists) r¢r,Úuse_purer§ÚHAVE_DNSPYTHONrÚdnsÚresolverÚqueryÚ exceptionZ DNSExceptionr`r9ÚtargetZto_textr5r¯r‹Ú_init_attributesr~rŽršÚ _connectionrrÇrQr)r+rprrär)rIr®Z srv_recordsZsrvrÉraÚerrmsgr@r@rArJsPÿ    ü   ÿ       ÿzSession.__init__cCs|Srer@rHr@r@rAÚ __enter__8szSession.__enter__cCs | ¡dSrerf©rIÚexc_typeÚ exc_valueÚ tracebackr@r@rAÚ__exit__;szSession.__exit__c CsÀtjdkrRdt ¡dkr d}ndt ¡dkr6d}nt ¡}d t ¡d¡}n>t ¡}t ¡d kr|d  d t ¡d¡}nd   t ƒdd …¡}t   d¡}|ddkr¬d}nd}t t ¡ƒ||t ¡dd  dd„tdd…Dƒ¡|dœ}|jd |¡d|jkr¼|jdD]¬}|jd|}t|tƒs:td |¡ƒ‚t|ƒdkrVtd |¡ƒ‚| d¡rptd |¡ƒ‚t|tƒsŒtd ||¡ƒ‚t|ƒd krªtd! ||¡ƒ‚||jd|<qd"S)#z5Setup default and user defined connection-attributes.rkZ64rÚx86_64Z32Úi386z Windows-{}r ÚDarwinz{}-{}ÚmacOSrirÁú ZGPLv2zGPL-2.0Z Commercialzmysql-connector-pythonrõcSsg|] }t|ƒ‘qSr@)r:)r¶r²r@r@rAr·asz,Session._init_attributes..é)Z_pidÚ _platformÚ_osZ _source_hostZ _client_nameZ_client_versionZ_client_licenserßrz)Attribute name '{}' must be a string typeé z4Attribute name '{}' exceeds 32 characters limit sizer8zJKey names in 'session-connect-attributes' cannot start with '_', found: {}z4Attribute name '{}' value '{}' must be a string typeizBAttribute name '{}' value: '{}' exceeds 1024 characters limit sizeN)r†r‡rüÚ architecturer`Ú win32_verÚmachinerýÚmac_verr<r-r/rþr:ÚgetpidrLÚ gethostnamer.r§r¡rërrrYÚ startswith)rIZ platform_archZos_verZlicense_chunksZclient_licenseZdefault_attributesÚ attr_nameÚ attr_valuer@r@rAr§>sd     ò  ÿþ þ þþzSession._init_attributescCstjS)zAbool: `True` to use pure Python Protobuf implementation. )r,r rHr@r@rAr †szSession.use_purecCs t|tƒstdƒ‚t |¡dS)Nz)'use_pure' option should be True or False)rëÚboolrr,Z set_use_pure)rIrr@r@rAr Œs cCs |jj ¡S)zzReturns `True` if the session is open. Returns: bool: Returns `True` if the session is open. )r¨rËr“rHr@r@rAr“’szSession.is_opencCs t|j|ƒSrM)r)r¨rNr@r@rAr)šs z Session.sqlcCs|jS)z~Returns the underlying connection. Returns: mysqlx.connection.Connection: The connection object. )r¨rHr@r@rArš¦szSession.get_connectioncCs | d¡ ¡}dd„| ¡DƒS)z°Returns the list of schemas in the current session. Returns: `list`: The list of schemas in the current session. .. versionadded:: 8.0.12 zSHOW DATABASEScSsg|] }|d‘qS)rr@)r¶Úrowr@r@rAr··sz'Session.get_schemas..)r)rprÖrØr@r@rAÚ get_schemas®szSession.get_schemascCs t||ƒS)zöRetrieves a Schema object from the current session by it's name. Args: name (string): The name of the Schema object to be retrieved. Returns: mysqlx.Schema: The Schema object with the given name. r©rIr‡r@r@rAÚ get_schema¹s zSession.get_schemacCsv|jj d¡}|rr| t t|ƒ¡¡ ¡ ¡}z |dd|krLt ||ƒWSWn"t k rpt d |¡ƒ‚YnXdS)aRetrieves a Schema object from the current session by the schema name configured in the connection settings. Returns: mysqlx.Schema: The Schema object with the given name at connect time. None: In case the default schema was not provided with the initialization data. Raises: :class:`mysqlx.ProgrammingError`: If the provided default schema does not exists. rÉrrŸN) r¨r®r¢r)Ú_SELECT_SCHEMA_NAME_QUERYr`rrprÖrrÿr)rIrÉÚresr@r@rAÚget_default_schemaÄs ÿ ÿ zSession.get_default_schemacCs|j dt t|ƒ¡d¡dS)z‹Drops the schema with the specified name. Args: name (string): The name of the Schema object to be retrieved. r)TN)r¨r9Ú_DROP_DATABASE_QUERYr`r+rÅr@r@rAÚ drop_schemaßs  ÿzSession.drop_schemacCs$|j dt t|ƒ¡d¡t||ƒS)z¬Creates a schema on the database and returns the corresponding object. Args: name (string): A string value indicating the schema name. r)T)r¨r9Ú_CREATE_DATABASE_QUERYr`r+rrÅr@r@rAÚ create_schemaès  ÿzSession.create_schemacCs|j ddd¡dS)z+Starts a transaction context on the server.r)zSTART TRANSACTIONTN©r¨r9rHr@r@rAÚstart_transactionószSession.start_transactioncCs|j ddd¡dS)zXCommits all the operations executed after a call to startTransaction(). r)ZCOMMITTNrÎrHr@r@rAÚcommit÷szSession.commitcCs|j ddd¡dS)zYDiscards all the operations executed after a call to startTransaction(). r)ZROLLBACKTNrÎrHr@r@rAÚrollbackýszSession.rollbackNcCsX|dkrd t ¡¡}n"t|tƒr2t| ¡ƒdkr:tdƒ‚|j  dd t |ƒ¡d¡|S)aCreates a transaction savepoint. If a name is not provided, one will be generated using the uuid.uuid1() function. Args: name (Optional[string]): The savepoint name. Returns: string: The savepoint name. Nz{0}rúInvalid SAVEPOINT namer)z SAVEPOINT {0}T) r`ÚuuidZuuid1rërrYÚstriprr¨r9r+rÅr@r@rAÚ set_savepoints  ÿþzSession.set_savepointcCs@t|tƒrt| ¡ƒdkr"tdƒ‚|j dd t|ƒ¡d¡dS)zRollback to a transaction savepoint with the given name. Args: name (string): The savepoint name. rrÒr)zROLLBACK TO SAVEPOINT {0}TN© rërrYrÔrr¨r9r`r+rÅr@r@rAÚ rollback_tos ÿþzSession.rollback_tocCs@t|tƒrt| ¡ƒdkr"tdƒ‚|j dd t|ƒ¡d¡dS)z{Release a transaction savepoint with the given name. Args: name (string): The savepoint name. rrÒr)zRELEASE SAVEPOINT {0}TNrÖrÅr@r@rAÚrelease_savepoint$s ÿþzSession.release_savepointcCs|j ¡t|jƒ|_dS)zCloses the session.N)r¨rArÇr§rHr@r@rArd0s z Session.closecCs|j ¡dS)z8Closes all underliying connections as pooled connectionsN)r¨rûrHr@r@rAÚclose_connections6szSession.close_connections)N)r”r•r–r—rJrªr¯r§r}r Úsetterr“r)ršrÄrÆrÉrËrÍrÏrÐrÑrÕr×rØrdrÙr@r@r@rArœùs2 1H          rœc@sZeZdZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dS)ÚClienta7Class defining a client, it stores a connection configuration. Args: connection_dict (dict): The connection information to connect to a MySQL server. options_dict (dict): The options to configure this client. .. versionadded:: 8.0.13 NcCs’||_|dkri}g|_t ¡|_| | dd¡¡| | dd¡¡| | dd¡¡|  | dd¡¡|j |jd<|j |jd<|j|jd <dS) NrPrQrRrrSÚenabledTržr7) r®ÚsessionsrÓZuuid4r7Ú_set_pool_sizer¢Ú_set_max_idle_timeÚ_set_queue_timeoutÚ_set_pool_enabledÚpooling_enabledrP)rIZconnection_dictZ options_dictr@r@rArJEs   zClient.__init__cCs|Srer@rHr@r@rArªVszClient.__enter__cCs | ¡dSrerfr«r@r@rAr¯YszClient.__exit__cCs@t|tƒst|tƒr|dks*td |¡ƒ‚|dkr6tn||_dS)a“Set the size of the pool. This method sets the size of the pool but it will not resize the pool. Args: pool_size (int): An integer equal or greater than 0 indicating the pool size. Raises: :class:`AttributeError`: If the pool_size value is not an integer greater or equal to 0. rzWPool max_size value must be an integer greater than 0, the given value {} is not valid.N)rërÂrfrRr`Ú_CNX_POOL_MAXSIZErP)rIZ pool_sizer@r@rArÞ\s ÿþzClient._set_pool_sizecCsRt|tƒst|tƒr|dks*td |¡ƒ‚||_|dkrs¸ý             ó X#hIEaD