
    Dh?                     J   d Z 	 ddlZddlmZ d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mZmZmZ dd
l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#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, ddl-m.Z. i Z/d Z0d Z1d Z2e2Z3ejh                  Z5ejl                  Z7g dZ8y# e$ r dZY w xY w)z9
MySQL Connector/Python - MySQL driver written in Python
    N   )CMySQLConnectionTF)version)MySQLConnection)ErrorWarningInterfaceErrorDatabaseErrorNotSupportedError	DataErrorIntegrityErrorProgrammingErrorOperationalErrorInternalErrorcustom_error_exception	PoolError)	FieldFlag	FieldTypeCharacterSetRefreshOption
ClientFlag)DateTime	TimestampBinaryDateFromTicksTimestampFromTicksTimeFromTicksSTRINGBINARYNUMBERDATETIMEROWIDapilevelthreadsafety
paramstyle)read_option_filesc                     ddl m}m}m} 	 | d   }|5  |t
        vr |di | t
        |<   n=t        t
        |   |      r*t
        |   j                  }d| v r| d   |k7  rt        d      ddd       	 t
        |   j                         S # t        $ r  |di | }Y w xY w# 1 sw Y   8xY w# t        $ r t        dj                  |            w xY w)	z Return a pooled MySQL connectionr   )MySQLConnectionPoolgenerate_pool_nameCONNECTION_POOL_LOCK	pool_name	pool_sizez)Size can not be changed for active pools.Nz)Failed getting connection from pool '{0}' )poolingr)   r*   r+   KeyError_CONNECTION_POOLS
isinstancer-   r   get_connectionAttributeErrorr	   format)kwargsr)   r*   r+   r,   
check_sizes         X/var/www/html/civilisation/venv/lib/python3.12/site-packages/mysql/connector/__init__.py_get_pooled_connectionr9   5   s     1;'	
 
 	5--+>+H+Hi())46IJ*95??Jv%{+z9 !4 5 5	5K +::<<#  1&00	1	5 	5  K7>>yIK 	KKs)   B	 AB 2B, 	BB B),$Cc            	         | j                         }	 |d   }|d= t        g d      }|D ]Z  }t        |j	                               |z
  }|s"t        dj                  t        |      dkD  rdnddj                  |                   |D ]0  }|j                         }|j                  |       	 t        d
i |c S  t        d	      # t        $ r t        d      w xY w# t        $ r Y aw xY w)a  Return a MySQL connection and try to failover if needed

    An InterfaceError is raise when no MySQL is available. ValueError is
    raised when the failover server configuration contains an illegal
    connection argument. Supported arguments are user, password, host, port,
    unix_socket and database. ValueError is also raised when the failover
    argument was not provided.

    Returns MySQLConnection instance.
    failoverzfailover argument not provided)userpasswordhostportunix_socketdatabaser,   r-   z4Unsupported connection argument {0} in failover: {1}r   s z, z-Could not failover: no MySQL server availabler.   )copyr0   
ValueErrorsetkeysr5   lenjoinupdateconnectr   r	   )r6   configr;   support_cnx_argsserverdiff
new_configs          r8   _get_failover_connectionrQ   U   s    [[]F;*% 	z	/0
  &6;;=!$44FMMt9q=CbIIdO%& &&  [[]
&!	(Z((	 H
II5  ;9::;,  		s   C -
CC	C*)C*c                     d|v rt        di |}t        di |S t        d|v d|v g      rt        d      d|v rd|v rt	        d      ddlm}  || i |S d|v rt        di |S 	 dd	lm} t        |D cg c]  }||v  c}      rt        di |S 	 |j                  d
d      }	 |d
= t        r|st        | i |S t!        | i |S c c}w # t        $ r Y Dw xY w# t        $ r Y =w xY w)a  Create or get a MySQL connection object

    In its simpliest form, Connect() will open a connection to a
    MySQL server and return a MySQLConnection object.

    When any connection pooling arguments are given, for example pool_name
    or pool_size, a pool is created or a previously one is used to return
    a PooledMySQLConnection.

    Returns MySQLConnection or PooledMySQLConnection.
    option_filesfabricr;   z-fabric and failover arguments can not be usedr,   zR'pool_name' argument is not supported with  MySQL Fabric. Use 'pool_size' instead.r   )rK   )CNX_POOL_ARGSuse_pureTr.   )r'   rK   allr	   r4   rT   rQ   	constantsrU   anyr9   	NameError
setdefaultr0   	HAVE_CEXTr   r   )argsr6   rP   fabric_connectrU   keyrV   s          r8   rK   rK      s>    &00
$$$
H
f 456LMM6&   "K L L5t.v.. V'1&11,7#v78)3F33 9   T2H:
 000///# 8   s6   (C 7C	C (C 	C 	CC	C)(C))%r   Connectr   r   r   r   r   r   r\   r   r   r	   r
   r   r   r   r   r   r   rK   r$   r%   r&   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r   )9__doc___mysql_connectorconnection_cextr   r\   ImportErrorrC   r   
connectionr   errorsr   r   r	   r
   r   r   r   r   r   r   r   r   rX   r   r   r   r   r   dbapir   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   optionfilesr'   r1   r9   rQ   rK   r`   VERSION__version_info__VERSION_TEXT__version____all__r.       r8   <module>ro      s   01 I  'H H H H ( ( ( ( (
 + K@(JV30h ?? ""u  Is   
B B"!B"