U
    e                  
   @   sp  d Z ddlZddlZddlZddlmZmZmZmZm	Z	m
Z
mZ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 ddlmZ dd	lmZmZmZmZmZ dd
lm Z  ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( dZ)zLddl*Z*ddl*m+Z+m,Z, ddl-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7 W n6 e8k
rV Z9 ze8de9 de9W 5 dZ9[9X Y nX dZ)G dd deZ:dS )z'Connection class using the C Extension.    N)AnyDictListOptionalSequenceTupleTypeUnion   )version)MySQLConnectionAbstract)CharacterSet
ClientFlag	FieldFlag
ServerFlagShutdownType)MySQLConverter)InterfaceErrorInternalErrorOperationalErrorProgrammingErrorget_mysql_exception)MySQLProtocol)CextEofPacketTypeCextResultTypeDescriptionTypeParamsSequenceOrDictTypeRowTypeStatsPacketType
StrOrBytesF)MySQLInterfaceErrorMySQLPrepStmt)
CMySQLCursorCMySQLCursorBufferedCMySQLCursorBufferedDictCMySQLCursorBufferedNamedTupleCMySQLCursorBufferedRawCMySQLCursorDictCMySQLCursorNamedTupleCMySQLCursorPreparedCMySQLCursorPreparedDictCMySQLCursorRawz2MySQL Connector/Python C Extension not available ()Tc                       s  e Zd ZdZedd fddZddddZddd	d
Zee	dddZ
eddddZdeddddZeedddZejeddddZeedddZejeddddZee	dddZddddZddddZeZedd d!Zedd"d#Zdee	e	dd'd(d)Zedd*d+d,Zeee d-d.d/Zeee	 dd0d1Zdee	 eeee   ee ee! e"ee ee# f d2d3d4Z$deeee   ee ee! e"ee e#f d5d6d7Z%ee dd8d9Z&ddd:d;Z'ddd<d=Z(ddd>d?Z)edd@dAdBZ*dee! e+dCdDdEZ,ee# ddFdGZ-e.e!dHdIdJZ/e!eee0e#e+f  dKdLdMZ1e!ddNdOdPZ2e!ddNdQdRZ3deee eeee0e#e+f  dSdTdUZ4e4Z5dee ee ee ee6e7  ee ee e7dVdWdXZ8ee	ddYdZZ9ee	dd[d\Z:eedd]d^Z;eedd_d`Z<eeddadbZ=e>e0e?e. e@ee.f f dcdddeZAdddfdgZBdeeee	eeeee ddj	dkdlZCeddmdnZDe	ee# dodpdqZEdddrdsZFdee	 ddtdudvZGeHddwdxZIe	ddydzd{ZJedd|d}ZKedd~dZLeedddZMeeeedddZNdeddddZOdee@eef  ee@eef  ddddZP  ZQS )CMySQLConnectionz6Class initiating a MySQL Connection using Connector/C.N)kwargsreturnc                    s   t stdd| _g | _tjtjtjt	j
ddd| _t dkrntj| jsntjdrhdnd| _d| _t   |r| jf | dS )	ZInitializationz0MySQL Connector/Python C Extension not availableNmysqlvendorpluginLinuxz/usr/lib64/mysql/pluginz/usr/lib/mysql/plugin)HAVE_CMYSQLRuntimeError_cmysql_columnsospathjoindirnameabspath_mysql_connector__file___plugin_dirplatformsystemexists	convertersuper__init__connect)selfr.   	__class__ `/var/www/html/assets/scripts/venv/lib/python3.8/site-packages/mysql/connector/connection_cext.pyrE   [   s*    

zCMySQLConnection.__init__)r/   c              
   C   sZ   t jd}|d dkrd}nd}| jd|ddd	 t jdd
 D t d dS )z!Add default connection attributes r   ZGPLv2zGPL-2.0Z
Commercialzmysql-connector-python.c                 S   s   g | ]}t |qS rJ   )str).0xrJ   rJ   rK   
<listcomp>   s     z<CMySQLConnection._add_default_conn_attrs.<locals>.<listcomp>   )Z_connector_nameZ_connector_licenseZ_connector_versionZ_source_hostN)	r   LICENSEsplit_conn_attrsupdater:   VERSIONsocketgethostname)rG   Zlicense_chunksZclient_licenserJ   rJ   rK   _add_default_conn_attrsx   s    z(CMySQLConnection._add_default_conn_attrsc              	   C   sR   | j  | j  | j  dddd| j  d| _| | jd | _t	| j dS )z<Gather information of the MySQL server before authenticationN)protocolserver_version_originalZserver_threadidcharsetserver_statusauth_pluginZ	auth_dataZcapabilitiesr\   )
r6   Zget_proto_infoZget_server_info	thread_idZst_server_capabilitiesZ
_handshakeZ_check_server_versionZ_server_versionr   Zset_mysql_versionrG   rJ   rJ   rK   _do_handshake   s    zCMySQLConnection._do_handshakec                 C   s
   | j  S )z6Returns the server status attribute of MYSQL structure)r6   Zst_server_statusra   rJ   rJ   rK   _server_status   s    zCMySQLConnection._server_status)r9   r/   c                 C   s   | j r| j | dS )zJset local_infile_in_path

        Set allow_local_infile_in_path.
        N)r6   Z!set_load_data_local_infile_option)rG   r9   rJ   rJ   rK   set_allow_local_infile_in_path   s    z/CMySQLConnection.set_allow_local_infile_in_pathT)valuer/   c                 C   s.   || _ | jr| j| | jr*| j| dS )zuToggle unicode mode

        Set whether we return string fields as unicode or not.
        Default is True.
        N)_use_unicoder6   use_unicoderC   set_unicoderG   re   rJ   rJ   rK   rh      s
    zCMySQLConnection.set_unicodec                 C   s   |  dd }|dkS )z#Get whether autocommit is on or offzSELECT @@session.autocommitr   r
   
info_queryri   rJ   rJ   rK   
autocommit   s    zCMySQLConnection.autocommitc              
   C   sT   z| j | || _W n8 tk
rN } zt|j|j|jd|W 5 d}~X Y nX dS )zToggle autocommitmsgerrnosqlstateN)r6   rl   Z_autocommitr    r   rn   ro   rp   rG   re   errrJ   rJ   rK   rl      s    
  c                 C   s   |  dd S )zGet the current databasezSELECT DATABASE()r   rj   ra   rJ   rJ   rK   database   s    zCMySQLConnection.databasec              
   C   sN   z| j | W n8 tk
rH } zt|j|j|jd|W 5 d}~X Y nX dS )zSet the current databaserm   Nr6   Z	select_dbr    r   rn   ro   rp   rq   rJ   rJ   rK   rs      s      c                 C   s   | j tj@ S )z'MySQL session has started a transaction)rc   r   ZSTATUS_IN_TRANSra   rJ   rJ   rK   in_transaction   s    zCMySQLConnection.in_transactionc                 C   s  t | jd }tj| j| j|| jp&d| j| j	| j
d| _| tjsLi | _| j| j| j| j| j| j| j| j| j| j| tjd| j| j| j| j| jd}| j d}|d k	r|j!dd d"|}| j dd k	r| j dd }| j dd	 }nd }d }|d k	rd
|kr|sd}| j#sx|$| j d| j d| j d|||| j dp\d| j dpld| j#d	 t%j&dkr| j'dkrd|d< z.| jj(f | | j)| j_*| j+r| j)| j+_,W n: t-k
r  } zt.|j/|j0|j1d|W 5 d }~X Y nX | 2  d S )Nr   )bufferedrawcharset_nameZconnection_timeoutrg   r_   Z
plugin_dirT)hostuserpassword	password1	password2	password3rs   portZclient_flagsZunix_socketcompressssl_disabledZ
conn_attrsZlocal_infileZload_data_local_diroci_config_fileZfido_callbacktls_versions)reverse,tls_ciphersuitesr
   zTLSv1.3ZTLS_AES_256_GCM_SHA384cacertkeyZverify_certFZverify_identity)	Zssl_caZssl_certZssl_keyZssl_cipher_suitesr   Ztls_cipher_suitesZssl_verify_certZssl_verify_identityr   ntZMySQLKerberosAuthPluginZuse_kerberos_gssapirm   )3r   get_info_charset_idr=   MySQL	_buffered_rawZ_connection_timeoutrf   Z_auth_pluginr?   r6   Zisset_client_flagr   ZCONNECT_ARGSrU   _host_user	_password
_password1
_password2
_password3	_database_portZ_client_flags_unix_socketZCOMPRESSZ_allow_local_infileZ_allow_local_infile_in_path_oci_config_fileZ_fido_callback_sslgetsortr:   Z_ssl_disabledrV   r8   nameZ_auth_plugin_classrF   _converter_str_fallbackconverter_str_fallbackrC   Zstr_fallbackr    r   rn   ro   rp   rb   )rG   rx   Z
cnx_kwargsr   Zssl_ciphersuitesr   rr   rJ   rJ   rK   _open_connection   s    






  z!CMySQLConnection._open_connectionc              
   C   sZ   | j rVz|   | j   W n8 tk
rT } zt|j|j|jd|W 5 d}~X Y nX dS )z Disconnect from the MySQL serverrm   N)r6   free_resultcloser    r   rn   ro   rp   )rG   rr   rJ   rJ   rK   r   +  s      zCMySQLConnection.closec                 C   s   | j   S )z8Return True if the connection to MySQL Server is closed.)r6   	connectedra   rJ   rJ   rK   	is_closed8  s    zCMySQLConnection.is_closedc                 C   s   | j r|   | j  S dS )z;Reports whether the connection to MySQL Server is availableF)r6   handle_unread_resultpingra   rJ   rJ   rK   is_connected<  s    
zCMySQLConnection.is_connectedFr
   r   )	reconnectattemptsdelayr/   c                 C   sT   |    z| j }W n tk
r*   Y n
X |r4dS |rH| j||d ntddS )a  Check availability of the MySQL server

        When reconnect is set to True, one or more attempts are made to try
        to reconnect to the MySQL server using the reconnect()-method.

        delay is the number of seconds to wait between each retry.

        When the connection is not available, an InterfaceError is raised. Use
        the is_connected()-method if you just want to check the connection
        without raising an error.

        Raises InterfaceError on errors.
        N)r   r   z$Connection to MySQL is not available)r   r6   r   AttributeErrorr   r   )rG   r   r   r   r   rJ   rJ   rK   r   D  s    zCMySQLConnection.ping)r]   r/   c                 C   s   | j | dS )z;Sets the default character set name for current connection.N)r6   Zset_character_set)rG   r]   rJ   rJ   rK   set_character_set_namea  s    z'CMySQLConnection.set_character_set_name)queryr/   c              
   C   s   d}zH| j | | j jr@| j  }| j  r@| j   td| j   W n8 tk
r } zt|j|j	|j
d|W 5 d}~X Y nX |S )z%Send a query which only returns 1 rowrJ   z'Query should not return more than 1 rowrm   N)r6   r   have_result_set	fetch_rowr   r   r    r   rn   ro   rp   )rG   r   	first_rowrr   rJ   rJ   rK   rk   e  s$    


  zCMySQLConnection.info_queryc                 C   s&   z| j  W S  tk
r    Y nX dS )zMySQL connection IDN)r6   r`   r    ra   rJ   rJ   rK   connection_idw  s
    zCMySQLConnection.connection_id)countbinarycolumnsrw   	prep_stmtr/   c              
   C   s  |r
|j n| j}| jr|s"td|dkr0| j}g }|dk	rL|dkrLtdd}z|r\|jn| jj}	| jrv| jd |	 }
|
r| js| jrt	|
}
t
|
D ](\}}|s| j| j| |
| |
|< qt|
}
||
 |d7 }|r||krq|	 }
q||
s*| |d }|r |  d| _n|   nd}W n^ tk
r } z>|r`|  tt|||   t|j|j|jd	|W 5 d}~X Y nX ||fS )
z8Get all or a subset of rows returned by the MySQL serverzNo result set availableNr   z$count should be 1 or higher, or NoneTr
   eofFrm   )r   unread_resultr6   r   r   r   r   rC   rw   list	enumerateZ	to_pythonr7   tupleappendfetch_eof_columnsr   _unread_resultr    r   rN   r   rn   ro   rp   )rG   r   r   r   rw   r   r   rowscounterr   rowi__eofrr   rJ   rJ   rK   get_rows  s`    	


  zCMySQLConnection.get_rows)r   r   rw   r   r/   c                 C   sP   z4| j d||||d\}}|r,|d |fW S d|fW S  tk
rJ   Y dS X dS )z.Get the next rows returned by the MySQL serverr
   )r   r   r   rw   r   r   N)NN)r   
IndexError)rG   r   r   rw   r   r   r   rJ   rJ   rK   get_row  s    

zCMySQLConnection.get_rowc                 C   s   | j r| j   | j  S dS )zReads the next resultN)r6   consume_resultnext_resultra   rJ   rJ   rK   r     s    

zCMySQLConnection.next_resultc                 C   s   | j r| j   dS )zFrees the resultN)r6   r   ra   rJ   rJ   rK   r     s    zCMySQLConnection.free_resultc                 C   s   | j r|   | j   dS )zCommit current transactionN)r6   r   commitra   rJ   rJ   rK   r     s    zCMySQLConnection.commitc                 C   s   | j r| j   | j   dS )zRollback current transactionN)r6   r   rollbackra   rJ   rJ   rK   r     s    
zCMySQLConnection.rollback)rs   r/   c              
   C   sN   z| j | W n8 tk
rH } zt|j|j|jd|W 5 d}~X Y nX dS )zChange the current databaserm   Nrt   )rG   rs   rr   rJ   rJ   rK   cmd_init_db  s      zCMySQLConnection.cmd_init_db)r   r/   c                 C   s   |r
|j n| jj }|std|r*| n| j }g | _|D ]N}| j|d t|d ddddt|d  tj@ t|d t|d f	 q>| j	| j
 d| jdS )	z Fetch EOF and column informationNo result set      N	      )Zstatus_flagwarning_count)r   r   )r   r6   r   Zfetch_fieldsr7   r   intr   ZNOT_NULLrc   st_warning_count)rG   r   r   fieldscolrJ   rJ   rK   r     s0    


z"CMySQLConnection.fetch_eof_columnsc                 C   s4   | j r0| j  | j  | j  | j  | jdS dS )z Fetch EOF and status information)r   Zfield_count	insert_idaffected_rowsr^   N)r6   r   Zst_field_countr   r   rc   ra   rJ   rJ   rK   fetch_eof_status  s    z!CMySQLConnection.fetch_eof_status)	statementr/   c              
   C   s^   | j stdz| j |}| j|_|W S  tk
rX } ztt||W 5 d}~X Y nX dS )zPrepares the SQL statementMySQL Connection not availableN)r6   r   Zstmt_preparer   r   r    r   rN   )rG   r   stmtrr   rJ   rJ   rK   cmd_stmt_prepare(  s    z!CMySQLConnection.cmd_stmt_prepare)statement_idargsr/   c              
   G   sj   z|j |  W n0 tk
r> } ztt||W 5 d}~X Y nX g | _|jsZd| _|  S d| _| |S )zExecutes the prepared statementNFT)	Zstmt_executer    r   rN   r7   r   r   r   r   )rG   r   r   rr   rJ   rJ   rK   cmd_stmt_execute4  s     z!CMySQLConnection.cmd_stmt_execute)r   r/   c                 C   s   | j rtd|  dS )zCloses the prepared statementUnread result foundN)r   r   Z
stmt_closerG   r   rJ   rJ   rK   cmd_stmt_closeF  s    zCMySQLConnection.cmd_stmt_closec                 C   s   | j rtd|  dS )zResets the prepared statementr   N)r   r   Z
stmt_resetr   rJ   rJ   rK   cmd_stmt_resetL  s    zCMySQLConnection.cmd_stmt_reset)r   rw   rv   raw_as_stringr/   c              
   C   s   |    |dkr| j}z0t|ts,|d}| jj||||| jd W n tk
r~ } zt	|j
|j|jd|W 5 d}~X Y nR tk
r } z4| jr| jn| j d| j }td|dfd|W 5 d}~X Y nX g | _| jjs|  S |  S )	z Send a query to the MySQL serverNzutf-8)rw   rv   r   Zquery_attrs)rn   rp   :i  zConnection not available.)ro   values)r   r   
isinstancebytesencoder6   r   Z_query_attrsr    r   ro   rn   rp   r   r   r   r   r   r7   r   r   r   )rG   r   rw   rv   r   rr   addrrJ   rJ   rK   	cmd_queryR  sD    


   zCMySQLConnection.cmd_query)rv   rw   preparedcursor_class
dictionarynamed_tupler/   c                    s  |  | |  std|dk	r<t|ts4td|| S |pD| j}|pN| j}d|dkrddO |dkrtdO |dkrdO |dkrd	O |dkrd
O ttt	t
ttttttd
}z| | W S  tk
r   d tdd fddtdD  dY nX dS )a  Instantiates and returns a cursor using C Extension

        By default, CMySQLCursor is returned. Depending on the options
        while connecting, a buffered and/or raw cursor is instantiated
        instead. Also depending upon the cursor options, rows can be
        returned as dictionary or named tuple.

        Dictionary and namedtuple based cursors are available with buffered
        output but not raw.

        It is possible to also give a custom cursor through the
        cursor_class parameter, but it needs to be a subclass of
        mysql.connector.cursor_cext.CMySQLCursor.

        Raises ProgrammingError when cursor_class is not a subclass of
        CursorBase. Raises ValueError when cursor is not available.

        Returns instance of CMySQLCursor or subclass.

        :param buffered: Return a buffering cursor
        :param raw: Return a raw cursor
        :param prepared: Return a cursor which uses prepared statements
        :param cursor_class: Use a custom cursor class
        :param dictionary: Rows are returned as dictionary
        :param named_tuple: Rows are returned as named tuple
        :return: Subclass of CMySQLCursor
        :rtype: CMySQLCursor or subclass
        MySQL Connection not available.Nz=Cursor class needs be to subclass of cursor_cext.CMySQLCursorr   Tr
      r   r      )
r   r
   r   rR   r      r   r   r      )rv   rw   r   r   r   z*Cursor not available with given criteria: z, c                    s$   g | ]}d |> @ dkr | qS )r
   r   rJ   )rO   r   r   Zcursor_typerJ   rK   rQ     s      z+CMySQLConnection.cursor.<locals>.<listcomp>r   )r   r   r   
issubclassr"   r   r   r   r#   r+   r&   r'   r$   r(   r%   r)   r*   KeyError
ValueErrorr:   range)rG   rv   rw   r   r   r   r   typesrJ   r   rK   cursor|  sX    %



zCMySQLConnection.cursorc                 C   s   | j jstd| j  S )z,Returns number of rows of current result setr   )r6   r   r   num_rowsra   rJ   rJ   rK   r     s    zCMySQLConnection.num_rowsc                 C   s   | j s
dS | j  S )zReturns number of warningsr   )r6   r   ra   rJ   rJ   rK   r     s    zCMySQLConnection.warning_countc                 C   s   | j s
dS | j jS )z"Check if a result set is availableF)r6   r   ra   rJ   rJ   rK   result_set_available  s    z%CMySQLConnection.result_set_availablec                 C   s   | j S )z)Check if there are unread results or rows)r   ra   rJ   rJ   rK   r     s    zCMySQLConnection.unread_resultc                 C   s
   | j  S )zCheck if there are more results)r6   more_resultsra   rJ   rJ   rK   r     s    zCMySQLConnection.more_results)paramsr/   c                    s   g }t |ttfr: jr, fdd|D }qƈ jj| }nt |tri } jr| D ](\}} j j	 j
|||< qVq| D ]\}} j|d ||< qntdt|j d| d|S )zPrepare parameters for statements

        This method is use by cursors to prepared parameters found in the
        list (or tuple) params.

        Returns dict.
        c              	      s(   g | ] } j  j  j |qS rJ   )rC   quoteescapeto_mysql)rO   re   ra   rJ   rK   rQ     s   z6CMySQLConnection.prepare_for_mysql.<locals>.<listcomp>r   zCould not process parameters: (z)), it must be of type list, tuple or dict)r   r   r   rC   r6   Zconvert_to_mysqldictitemsr   r  r  r   type__name__)rG   r   resultr   re   rJ   ra   rK   prepare_for_mysql  s(    


z"CMySQLConnection.prepare_for_mysqlc                 C   s   | j   dS )zlConsume the current result

        This method consume the result by reading (consuming) all rows.
        N)r6   r   ra   rJ   rJ   rK   consume_results  s    z CMySQLConnection.consume_results -   )	usernamer{   rs   r]   r|   r}   r~   r   r/   c	           
   
   C   sh   z| j ||||||| W n8 tk
rT }	 zt|	j|	j|	jd|	W 5 d}	~	X Y nX || _|   dS )z!Change the current logged in userrm   N)	r6   Zchange_userr    r   rn   ro   rp   r   _post_connection)
rG   r  r{   rs   r]   r|   r}   r~   r   rr   rJ   rJ   rK   cmd_change_user  s(    
  z CMySQLConnection.cmd_change_userc                 C   s   | j  }|r|   |S )zResets the session state without re-authenticating

        Reset command only works on MySQL server 5.7.3 or later.
        The result is True for a successful reset otherwise False.

        Returns bool
        )r6   Zreset_connectionr  )rG   resrJ   rJ   rK   cmd_reset_connection>  s    
z%CMySQLConnection.cmd_reset_connection)optionsr/   c              
   C   sZ   z|    | j| W n8 tk
rP } zt|j|j|jd|W 5 d}~X Y nX |  S )z,Send the Refresh command to the MySQL serverrm   N)	r   r6   refreshr    r   rn   ro   rp   r   )rG   r  rr   rJ   rJ   rK   cmd_refreshK  s      zCMySQLConnection.cmd_refreshc                 C   s   |    dS )z,Close the current connection with the serverN)r   ra   rJ   rJ   rK   cmd_quitW  s    zCMySQLConnection.cmd_quit)shutdown_typer/   c              
   C   s   | j std|r*t|s$td|}ntj}z| j | W n8 tk
rx } zt|j	|j
|jd|W 5 d}~X Y nX |   dS )zShut down the MySQL Serverr   zInvalid shutdown typerm   N)r6   r   r   r   r   ZSHUTDOWN_DEFAULTshutdownr    r   rn   ro   rp   r   )rG   r  levelrr   rJ   rJ   rK   cmd_shutdown[  s$    
  zCMySQLConnection.cmd_shutdownc              
   C   sf   |    z| j }t j|ddW S  ttfk
r` } zt|j|j	|j
d|W 5 d}~X Y nX dS )z'Return statistics from the MySQL serverF)Zwith_headerrm   N)r   r6   statr   Zparse_statisticsr    r   r   rn   ro   rp   )rG   r  rr   rJ   rJ   rK   cmd_statisticso  s    
  zCMySQLConnection.cmd_statistics)	mysql_pidr/   c                 C   s&   t |tstd| d|  dS )zKill a MySQL processzMySQL PID must be intzKILL N)r   r   r   rk   )rG   r  rJ   rJ   rK   cmd_process_kill{  s    
z!CMySQLConnection.cmd_process_killc                 C   s   t dS )zSend the DEBUG commandNNotImplementedErrorra   rJ   rJ   rK   	cmd_debug  s    zCMySQLConnection.cmd_debugc                 C   s   t dS )zSend the PING commandNr  ra   rJ   rJ   rK   cmd_ping  s    zCMySQLConnection.cmd_ping)
statementsr/   c                 C   s   t dS )z/Send one or more statements to the MySQL serverNr  )rG   r"  rJ   rJ   rK   cmd_query_iter  s    zCMySQLConnection.cmd_query_iter)r   param_iddatar/   c                 C   s   t dS )zSend data for a columnNr  )rG   r   r$  r%  rJ   rJ   rK   cmd_stmt_send_long_data  s    z(CMySQLConnection.cmd_stmt_send_long_data)r   r/   c                 C   s4   |dkr| j n| j}| jr$|   n|r0tddS )z'Check whether there is an unread resultTr   N)r   r   Zcan_consume_resultsr
  r   )rG   r   r   rJ   rJ   rK   r     s
    
z%CMySQLConnection.handle_unread_result)user_variablessession_variablesr/   c              
   C   s   |   std|  sbz,| | j| j| j| j| j| j	| j
| j W n tk
r`   |   Y nX |sj|r|  }|r| D ]\}}|d| d|f q~|r| D ]\}}|d| d|f q|  dS )a  Clears the current active session

        This method resets the session state, if the MySQL server is 5.7.3
        or later active session will be reset without re-authenticating.
        For other server versions session will be reset by re-authenticating.

        It is possible to provide a sequence of variables and their values to
        be set after clearing the session. This is possible for both user
        defined variables and session variables.
        This method takes two arguments user_variables and session_variables
        which are dictionaries.

        Raises OperationalError if not connected, InternalError if there are
        unread results and InterfaceError on errors.
        r   zSET @`z` = %szSET SESSION `N)r   r   r  r  r   r   r   r   r   r   r   r   r   r   r   r  executer   )rG   r'  r(  curr   re   rJ   rJ   rK   reset_session  s2    
zCMySQLConnection.reset_session)T)Fr
   r   )NFNNN)FNNN)N)NFF)NNNNNN)r  r  r  r  r  r  r  N)N)F)NN)Rr  
__module____qualname____doc__r   rE   rZ   rb   propertyr   rc   rN   rd   boolrh   rl   setterrs   ru   r   r   Z
disconnectr   r   r   r   r   r   r   rk   r   r   r   r!   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	   r   r   r   r   Z_execute_queryr   r"   r   r   r   r   r   r   r   r   r   r	  r
  r  r  r  r  r  r   r  r  r   r!  r#  r&  r   r+  __classcell__rJ   rJ   rH   rK   r-   X   s.  	
	Q     
A    

 # 	   (      
S'	          
  r-   );r.  r8   r@   rX   typingr   r   r   r   r   r   r   r	   r  r   Z	abstractsr   	constantsr   r   r   r   r   
conversionr   errorsr   r   r   r   r   r[   r   r   r   r   r   r   r   r   r   r4   r=   r    r!   Zcursor_cextr"   r#   r$   r%   r&   r'   r(   r)   r*   r+   ImportErrorexcr-   rJ   rJ   rJ   rK   <module>   s0   ($
4
