$24 GRAYBYTE WORDPRESS FILE MANAGER $17

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.15.130 | ADMIN IP 216.73.216.174
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/hc_python/lib/python3.12/site-packages/mysql/connector/__pycache__/

HOME
Current File : /opt/hc_python/lib/python3.12/site-packages/mysql/connector/__pycache__//conversion.cpython-312.pyc
�

H��gM���dZddlZddlZddlmZddlmZmZmZddl	m
Z
mZmZddl
mZGd�d	e�ZGd
�de�Zy)z"Converting MySQL and Python types
�N)�Decimal�)�	FieldType�	FieldFlag�CharacterSet)�PY2�
NUMERIC_TYPES�
struct_unpack)�
HexLiteralc�>�eZdZdZd
d�Zd�Zdd�Zd�Zd�Zd�Z	d�Z
y	)�MySQLConverterBasez�Base class for conversion classes

    All class dealing with converting to and from MySQL data types must
    be a subclass of this class.
    c��d|_d|_d|_d|_d|_|j|�|j
|�i|_y)Nr)�python_types�mysql_types�charset�
charset_id�use_unicode�set_charset�set_unicode�_cache_field_types��selfrrs   �q/opt/hc_python/lib64/python3.12/site-packages/../../../lib/python3.12/site-packages/mysql/connector/conversion.py�__init__zMySQLConverterBase.__init__+sL�� �������������������!�����%�"$���c��|dk(rd}|�||_nd|_tj|j�d|_y)zSet character set�utf8mb4�utf8Nr)rr�get_charset_infor)rrs  rrzMySQLConverterBase.set_charset5s@���i���G���"�D�L�"�D�L�&�7�7����E�a�H��rc��||_y)zSet whether to use UnicodeN)r�r�values  rrzMySQLConverterBase.set_unicode@s
�� ��rc��|jjj�}	t|dj	|��|�S#t
$r|cYSwxYw)�!Convert Python data type to MySQL�
_{0}_to_mysql)�	__class__�__name__�lower�getattr�format�AttributeError�rr"�	type_names   r�to_mysqlzMySQLConverterBase.to_mysqlDsR���O�O�,�,�2�2�4�	�	�C�7�4��!7�!7�	�!B�C�E�J�J���	��L�	�s� A�A�Ac�|�|dk(s|�|dtjk7ry|jsYi|_tjj	�D]1\}}	t|dj
|��|j|d<�3	|j|d||�S#t$rY�YwxYw#t$r|cYSwxYw)�!Convert MySQL data type to Python�Nr�_{0}_to_pythonr)	r�BITr�desc�itemsr)r*r+�KeyError)r�vtyper"�name�infos     r�	to_pythonzMySQLConverterBase.to_pythonLs���
�W���
�5��8�y�}�}�3L���&�&�&(�D�#�'�n�n�2�2�4�
��d��7>��.�5�5�d�;�8=�D�+�+�D��G�4�5�	�4�4�*�*�5��8�4�U�E�B�B��&������	��L�	�s$�+B�B-�	B*�)B*�-B;�:B;c��|S)z"Escape buffer for sending to MySQL��r�bufs  r�escapezMySQLConverterBase.escapebs���
rc��t|�S)z!Quote buffer for sending to MySQL��strr=s  r�quotezMySQLConverterBase.quotefs���3�x�rN)rT)T)r'�
__module__�__qualname__�__doc__rrrr.r:r?rCr<rrr
r
$s+���%�	I�!���,�rr
c�$�eZdZdZd$d�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd%d�ZeZd%d�ZeZeZeZeZeZ d%d�Z!e!Z"d%d�Z#d%d�Z$d%d�Z%e%Z&d%d�Z'd%d�Z(e(Z)d%d �Z*d%d!�Z+d%d"�Z,e,Z-d%d#�Z.e.Z/e.Z0e.Z1y)&�MySQLConvertera�Default conversion class for MySQL Connector/Python.

     o escape method: for escaping values send to MySQL
     o quoting method: for quoting values send to MySQL in statements
     o conversion mapping: maps Python and MySQL data types to
       function for converting them.

    Whenever one needs to convert values differently, a converter_class
    argument can be given while instantiating a new connection like
    cnx.connect(converter_class=CustomMySQLConverterClass).

    Nc�@�tj|||�i|_y�N)r
rrrs   rrzMySQLConverter.__init__ys���#�#�D�'�;�?�"$��rc��|�|St|t�r|St|ttf�rn|j	dd�}|j	dd�}|j	dd�}|j	dd�}|j	d	d
�}|j	dd�}|S|j	d
d�}|j	dd�}|j	dd�}|j	dd�}|j	dd�}|j	dd�}|S)z�
        Escapes special characters as they are expected to by when MySQL
        receives them.
        As found in MySQL source mysys/charset.c

        Returns the value if not a string, or the escaped string.
        �\s\\�
s\n�
s\r�'s\'�"s\"�s\�\z\\�
z\n�
z\r�'z\'�"z\"�z\)�
isinstancer	�bytes�	bytearray�replacer!s  rr?zMySQLConverter.escape}s����=��L�
��}�
-��L��e�e�Y�/�0��M�M�%��1�E��M�M�%��0�E��M�M�%��0�E��M�M�'�;�7�E��M�M�'�;�7�E��M�M�'�;�7�E���
�M�M�$��/�E��M�M�$��.�E��M�M�$��.�E��M�M�&�*�5�E��M�M�&�*�5�E��M�M�&�*�5�E��rc��t|t�rFtr&t|t�rt	|�St|�St|�j
d�St|td��rtd�Std|zdz�S)a
        Quote the parameters for commands. General rules:
          o numbers are returns as bytes using ascii codec
          o None is returned as bytearray(b'NULL')
          o Everything else is single quoted '<buf>'

        Returns a bytearray object.
        �asciiNsNULLrO)	rXr	r�float�reprrB�encode�typerZr=s  rrCzMySQLConverter.quote�sn���c�=�)���c�5�)���9�$��s�8�O��3�x���w�/�/�
��T�$�Z�
(��W�%�%��T�C�Z�$�.�/�/rc���|jjj�}	t|dj	|��|�S#t
$rt
dj	|���wxYw)r$r%z0Python '{0}' cannot be converted to a MySQL type)r&r'r(r)r*r+�	TypeErrorr,s   rr.zMySQLConverter.to_mysql�si���O�O�,�,�2�2�4�	�	<�C�7�4��!7�!7�	�!B�C�E�J�J���	<��)�)/��	�):�<�
<�	<�s� A�$A+c�F�|dk(r|dtjk7ry|�y|jsYi|_tjj	�D]1\}}	t|dj
|��|j|d<�3	|j|d||�S#t$rY�YwxYw#t$r(	|jd�cYS#t$r|cYcYSwxYwt$r}t|�d|d�d���d}~wt$r}t|�d|d�d���d}~w�xYw)r0rrNr2�utf-8z (field �))
rr3rr4r5r)r*r+r6�decode�UnicodeDecodeError�
ValueErrorrc)rr7r"r8r9�errs      rr:zMySQLConverter.to_python�s+���A�:�%��(�i�m�m�3���=���&�&�&(�D�#�'�n�n�2�2�4�
��d��7>��.�5�5�d�;�8=�D�+�+�D��G�4�5�
	�4�4�*�*�5��8�4�U�E�B�B��&������	�
��|�|�G�,�,��%�
���
���	@���U�1�X�>�?�?���	?��s�E�!�H�=�>�>��	��sZ�+B�B.�	B+�*B+�.	D �8C�D �C�D �C�D �&C:�:D �D�D c��t|�S�zConvert value to int��intr!s  r�
_int_to_mysqlzMySQLConverter._int_to_mysql�����5�z�rc��t|�Srlrmr!s  r�_long_to_mysqlzMySQLConverter._long_to_mysql�rprc��t|�S)zConvert value to float�r^r!s  r�_float_to_mysqlzMySQLConverter._float_to_mysql�����U�|�rc�F�trt|�S|j|�S)zConvert value to string)rrB�_unicode_to_mysqlr!s  r�
_str_to_mysqlzMySQLConverter._str_to_mysql�s ����u�:���%�%�e�,�,rc���|j}|j}|dk(rd}tj|�d}|j	|�}|tj
vrd|vrt
||�S|S)zConvert unicode�binaryrrrL)rrrrr`�slash_charsetsr)rr"rr�encodeds     rrxz MySQLConverter._unicode_to_mysql�sl���,�,���_�_�
��h���G�%�6�6�w�?��B�J��,�,�w�'����4�4�4��'�!�!�%��1�1��rc��|S�zConvert value to bytesr<r!s  r�_bytes_to_mysqlzMySQLConverter._bytes_to_mysql�s���rc��t|�Sr)rYr!s  r�_bytearray_to_mysqlz"MySQLConverter._bytearray_to_mysql�rvrc�
�|ryy)zConvert value to booleanrrr<r!s  r�_bool_to_mysqlzMySQLConverter._bool_to_mysqls����rc��y)z�
        This would return what None would be in MySQL, but instead we
        leave it None and return it right away. The actual conversion
        from None to NULL happens in the quoting functionality.

        Return None.
        Nr<r!s  r�_nonetype_to_mysqlz!MySQLConverter._nonetype_to_mysqls��rc	��|jrnd}|j|j|j|j|j
|j|j|j�jd�Sd}|j|j|j|j|j
|j|j�jd�S)z�
        Converts a datetime instance to a string suitable for MySQL.
        The returned string has format: %Y-%m-%d %H:%M:%S[.%f]

        If the instance isn't a datetime.datetime type, it return None.

        Returns a bytes.
        z5{0:d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:06d}r]z-{0:d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d})	�microsecondr*�year�month�day�hour�minute�secondr`)rr"�fmts   r�_datetime_to_mysqlz!MySQLConverter._datetime_to_mysqls������I�C��:�:��
�
�E�K�K�����
�
�E�L�L�%�,�,��!�!�#�$*�6�'�?�
3�
>���z�z��J�J����U�Y�Y��J�J����e�l�l�4�4:�F�7�O�	Drc��dj|j|j|j�j	d�S)z�
        Converts a date instance to a string suitable for MySQL.
        The returned string has format: %Y-%m-%d

        If the instance isn't a datetime.date type, it return None.

        Returns a bytes.
        z{0:d}-{1:02d}-{2:02d}r])r*r�r�r�r`r!s  r�_date_to_mysqlzMySQLConverter._date_to_mysql&s4��'�-�-�e�j�j�%�+�+�.3�i�i�9�9?����	Irc��|jr |jd�jd�S|jd�jd�S)z�
        Converts a time instance to a string suitable for MySQL.
        The returned string has format: %H:%M:%S[.%f]

        If the instance isn't a datetime.time type, it return None.

        Returns a bytes.
        z%H:%M:%S.%fr]z%H:%M:%S)r��strftimer`r!s  r�_time_to_mysqlzMySQLConverter._time_to_mysql2sA������>�>�-�0�7�7��@�@��~�~�j�)�0�0��9�9rc�L�tjd|�jd�S)z�
        Converts a time.struct_time sequence to a string suitable
        for MySQL.
        The returned string has format: %Y-%m-%d %H:%M:%S

        Returns a bytes or None when not valid.
        z%Y-%m-%d %H:%M:%Sr])�timer�r`r!s  r�_struct_time_to_mysqlz$MySQLConverter._struct_time_to_mysql?s!���}�}�0�%�8�?�?��H�Hrc���t|jdz|jz�}|jr3d}|jdkrd|jz
}|dz}n|j}nd}|jdkrd|z}t	|d�\}}t	|d	�\}}|jr|j|||�}	n|j|||�}	tr|	S|	jd
�S)z�
        Converts a timedelta instance to a string suitable for MySQL.
        The returned string has format: %H:%M:%S

        Returns a bytes.
        i�Qz{0:02d}:{1:02d}:{2:02d}.{3:06d}ri@Brz{0:02d}:{1:02d}:{2:02d}�-i�<r])�abs�days�seconds�microseconds�divmodr*rr`)
rr"r�r��mcs�hours�	remainder�mins�secs�results
          r�_timedelta_to_mysqlz"MySQLConverter._timedelta_to_mysqlIs����e�j�j�5�(�5�=�=�8�9�����3�C��z�z�A�~��� 2� 2�2���1����(�(��+�C��:�:��>���)�C�#�G�T�2���	��i��,���t�����Z�Z��t�T�3�7�F��Z�Z��t�T�2�F���M��=�=��)�)rc�X�t|t�rt|�jd�Sy)z�
        Converts a decimal.Decimal instance to a string suitable for
        MySQL.

        Returns a bytes or None when not valid.
        r]N)rXrrBr`r!s  r�_decimal_to_mysqlz MySQLConverter._decimal_to_mysqlls&���e�W�%��u�:�$�$�W�-�-�rc��d}dgt|�z}|jsYi|_tjj	�D]1\}}	t|dj
|��|j|d<�3|D]O}|d}||dk(r|tjk7s||�|dz
}�.	|j||||�||<|dz
}�Qt!|�S#t$rY��wxYw#t$r3	||jd�||<n#t$r||||<YnwxYwY�\ttf$r)}	dj
t|	�|d�|	_�d}	~	wwxYw)a Convert a MySQL text result row to Python types

        The row argument is a sequence containing text result returned
        by a MySQL server. Each value of the row is converted to the
        using the field type information in the fields argument.

        Returns a tuple.
        rNr2rrez{0} (field {1}))�lenrrr4r5r)r*r+r3r6rgrhrircrB�message�tuple)
r�row�fields�ir�r8r9�field�
field_typerjs
          r�
row_to_pythonzMySQLConverter.row_to_pythonxsx��
�����F��#���&�&�&(�D�#�'�n�n�2�2�4�
��d��7>��.�5�5�d�;�8=�D�+�+�D��G�4�5��E��q��J��A��!��
�i�m�m� ;��A����Q����

�?�D�3�3�J�?��A���N��q�	�
��F�A�)�,�V�}���5&������
'�'� #�A��
�
�g� 6�F�1�I��)�'� #�A��F�1�I�'���	�*�
�/�6�6�s�3�x��q��J�����
�sT�
+C�(C%�	C"�!C"�%	E�/D�E�D�E�D�E� E�.$E�Ec��t|�S)z.
        Returns value as float type.
        rt�rr"r4s   r�_FLOAT_to_pythonzMySQLConverter._FLOAT_to_python�s���U�|�rc��t|�S)z,
        Returns value as int type.
        rmr�s   r�_INT_to_pythonzMySQLConverter._INT_to_python�����5�z�rc�N�|j|j�}t|�S)z5
        Returns value as a decimal.Decimal.
        )rgrr)rr"r4�vals    r�_DECIMAL_to_pythonz!MySQLConverter._DECIMAL_to_python�s ���l�l�4�<�<�(���s�|�rc��t|�S)z,
        Returns value as str type.
        rAr�s   r�_strzMySQLConverter._str�r�rc�h�|}t|�dkrddt|�z
z|z}td|�dS)z!Returns BIT columntype as integer�r1z>Qr)r�r
)rr"�dsc�int_vals    r�_BIT_to_pythonzMySQLConverter._BIT_to_python�s=�����w�<�!����S��\�!1�2�W�<�G��T�7�+�A�.�.rc��	|jd�}tjt|d�t|d�t|d��S#t$rYywxYw)zA
        Returns DATE column type as datetime.date type.
        �-rr�N)�split�datetime�daternri)rr"r��partss    r�_DATE_to_pythonzMySQLConverter._DATE_to_python�sR��	��K�K��%�E��=�=��U�1�X���E�!�H�
�s�5��8�}�M�M���	��	�s�AA�	A�Ac��d}	|jd�\}}t|jdd��}	|jd�D�cgc]
}t|���c}\}}}	|ddk(s|ddk(r	||	|}}	}t	j
|||	|�	�}|S#t$r|}d}Y�pwxYwcc}w#t$rtd
j
|���wxYw)zA
        Returns TIME column type as datetime.time type.
        N�.��0r�:�-r�)r��minutesr�r�z2Could not convert {0} to python datetime.timedelta)r�rn�ljustrir��	timedeltar*)
rr"r��time_val�hmsr��dr�r�r�s
          r�_TIME_to_pythonzMySQLConverter._TIME_to_python�s�����	����T�*�J�S�#��c�i�i��4�(�)�C�	�36�9�9�T�?�"C�?�a�3�q�6�?�"C��U�D�$��Q�x�2�~��q��S��#'�%�$����C�d���)�)��t�26�S�J�H��O���	��C��C�	��#D��
�	��D�K�K����
�	�s.�/B�B,�B'�9B,�
B$�#B$�'B,�,$Cc��d}	|jd�\}}t|�dkDr0|jd�\}}t|jdd��}n|}d}|jd�D�cgc]
}t|���c}|jd	�D�cgc]
}t|���c}z|gz}	t	j|	�}|Scc}wcc}w#t
$rd}Y|SwxYw)
zI
        Returns DATETIME column type as datetime.datetime type.
        N� r�r�r�r�rr�r�)r�r�rnr�r�ri)
rr"r��datetime_val�date_�time_r�r�r��dtvals
          r�_DATETIME_to_pythonz"MySQLConverter._DATETIME_to_python�s�����	 �"�[�[��.�N�U�E��5�z�A�~�"�[�[��.�
��c��#�)�)�A�t�,�-������%*�[�[��%6�7�%6��S��V�%6�7�%(�Y�Y�t�_�5�_��S��V�_�5�6�9<��@�E�#�,�,�e�4�L����
8��5���	 ��L���	 �s0�A)C
�-C�?C
�C�&C
�
C
�
C�Cc�T�	t|�}|S#t$rtd|z��wxYw)z#Returns YEAR column type as integerz"Failed converting YEAR to int (%s))rnri)rr"r4r�s    r�_YEAR_to_pythonzMySQLConverter._YEAR_to_pythons<��	K��u�:�D�����	K��A�E�I�J�J�	K�s��'c���d}|j|j�}|s
t�S	t|jd��}|S#t$rt	d|z��wxYw)z�Returns SET column type as set

        Actually, MySQL protocol sees a SET as a string type field. So this
        code isn't called directly, but used by STRING_to_python() method.

        Returns SET column type as a set.
        N�,z'Could not convert set %s to a sequence.)rgr�setr�ri)rr"r��set_typer�s     r�_SET_to_pythonzMySQLConverter._SET_to_pythonsh�����l�l�4�<�<�(����5�L�	P��3�9�9�S�>�*�H�����	P��F��N�O�O�	P�s�A�Ac�&�|�@|dtjzr|j||�S|dtjzr|S|jdk(r|St|ttf�r'|jr|j|j�S|S)z�
        Note that a SET is a string too, but using the FieldFlag we can see
        whether we have to split it.

        Returns string typed columns as string type.
        �r{)
r�SETr��BINARYrrXrYrZrrg�rr"r�s   r�_STRING_to_pythonz MySQLConverter._STRING_to_python&s����?��1�v�	�
�
�%��*�*�5�#�6�6��1�v�	�(�(�(����<�<�8�#��L��e�e�Y�/�0�T�5E�5E��<�<����-�-��rc�|�|�)|dtjzrtr|St|�S|j	||�S)z Convert BLOB data type to Pythonr�)rr�rrYr�r�s   r�_BLOB_to_pythonzMySQLConverter._BLOB_to_python=s>���?��1�v�	�(�(�(�� �L� ��<�'��%�%�e�S�1�1r)NTrJ)2r'rDrErFrr?rCr.r:rorrruryrxr�r�r�r�r�r�r�r�r�r�r�r��_DOUBLE_to_pythonr��_TINY_to_python�_SHORT_to_python�_INT24_to_python�_LONG_to_python�_LONGLONG_to_pythonr��_NEWDECIMAL_to_pythonr�r�r��_NEWDATE_to_pythonr�r��_TIMESTAMP_to_pythonr�r�r��_VAR_STRING_to_pythonr��_LONG_BLOB_to_python�_MEDIUM_BLOB_to_python�_TINY_BLOB_to_pythonr<rrrHrHks���%��80�,<��B���-������D�*
I�:�I�!*�F
�,�\�)���%�O�%��%��$�O�(���/���/��)���0�*/����$�*.��	2�+��,��*�rrH)rFr�r��decimalr�	constantsrrr�catch23rr	r
�custom_typesr�objectr
rHr<rr�<module>rsB��0����9�9�6�6�$�D��D�N_+�'�_+r


Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
4 Apr 2025 8.03 AM
root / root
0755
__init__.cpython-312.pyc
6.22 KB
4 Apr 2025 8.03 AM
root / root
0644
abstracts.cpython-312.pyc
45.927 KB
4 Apr 2025 8.03 AM
root / root
0644
authentication.cpython-312.pyc
6.945 KB
4 Apr 2025 8.03 AM
root / root
0644
catch23.cpython-312.pyc
3.324 KB
4 Apr 2025 8.03 AM
root / root
0644
charsets.cpython-312.pyc
5.954 KB
4 Apr 2025 8.03 AM
root / root
0644
connection.cpython-312.pyc
46.72 KB
4 Apr 2025 8.03 AM
root / root
0644
connection_cext.cpython-312.pyc
26.627 KB
4 Apr 2025 8.03 AM
root / root
0644
constants.cpython-312.pyc
24.672 KB
4 Apr 2025 8.03 AM
root / root
0644
conversion.cpython-312.pyc
23.326 KB
4 Apr 2025 8.03 AM
root / root
0644
cursor.cpython-312.pyc
55.982 KB
4 Apr 2025 8.03 AM
root / root
0644
cursor_cext.cpython-312.pyc
34.614 KB
4 Apr 2025 8.03 AM
root / root
0644
custom_types.cpython-312.pyc
1.353 KB
4 Apr 2025 8.03 AM
root / root
0644
dbapi.cpython-312.pyc
2.406 KB
4 Apr 2025 8.03 AM
root / root
0644
errorcode.cpython-312.pyc
50.409 KB
4 Apr 2025 8.03 AM
root / root
0644
errors.cpython-312.pyc
9.643 KB
4 Apr 2025 8.03 AM
root / root
0644
network.cpython-312.pyc
21.664 KB
4 Apr 2025 8.03 AM
root / root
0644
optionfiles.cpython-312.pyc
13.544 KB
4 Apr 2025 8.03 AM
root / root
0644
pooling.cpython-312.pyc
13.969 KB
4 Apr 2025 8.03 AM
root / root
0644
protocol.cpython-312.pyc
30.848 KB
4 Apr 2025 8.03 AM
root / root
0644
utils.cpython-312.pyc
10.057 KB
4 Apr 2025 8.03 AM
root / root
0644
version.cpython-312.pyc
0.684 KB
4 Apr 2025 8.03 AM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF