/var/opt/nydus/ops/mysql/connector/__pycache__
NameSizeModeActions
abstracts.cpython-312.pyc1263050644editdlrm
authentication.cpython-312.pyc148150644editdlrm
charsets.cpython-312.pyc102270644editdlrm
connection.cpython-312.pyc705380644editdlrm
connection_cext.cpython-312.pyc485700644editdlrm
constants.cpython-312.pyc482270644editdlrm
conversion.cpython-312.pyc315540644editdlrm
cursor.cpython-312.pyc587990644editdlrm
cursor_cext.cpython-312.pyc497900644editdlrm
custom_types.cpython-312.pyc13400644editdlrm
dbapi.cpython-312.pyc30230644editdlrm
errorcode.cpython-312.pyc907520644editdlrm
errors.cpython-312.pyc133090644editdlrm
logger.cpython-312.pyc3390644editdlrm
network.cpython-312.pyc319440644editdlrm
optionfiles.cpython-312.pyc145250644editdlrm
pooling.cpython-312.pyc273930644editdlrm
protocol.cpython-312.pyc471850644editdlrm
tls_ciphers.cpython-312.pyc78190644editdlrm
types.cpython-312.pyc25860644editdlrm
utils.cpython-312.pyc281810644editdlrm
version.cpython-312.pyc6900644editdlrm
_decorating.cpython-312.pyc39980644editdlrm
_scripting.cpython-312.pyc157000644editdlrm
__init__.cpython-312.pyc17090644editdlrm
Edit: /var/opt/nydus/ops/mysql/connector/__pycache__/conversion.cpython-312.pyc (31554B)
N jjdZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z m Z m Z mZmZmZmZmZddlmZmZmZmZmZmZddlmZdd lmZmZmZm Z m!Z!dd l"m#Z#d Z$Gd d Z%Gdde%Z&y)z!Converting MySQL and Python typesN)Decimal)Enum)AnyCallableDictListOptionalSetTupleUnion)MYSQL_VECTOR_TYPE_CODE!NATIVE_SUPPORTED_CONVERSION_TYPES CharacterSet FieldFlag FieldTypeSQLMode) HexLiteral)DescriptionTypeMySQLConvertibleTypeMySQLProducedTypePythonProducedType StrOrBytes) NUMERIC_TYPESz.Could not convert '{value}' to python {pytype}c eZdZdZ ddeedededdfdZ ddeedeeddfd Z dd eddfd Z d e de e e ffd Zd ed eedefdZe dd edee eefdefdZededefdZy)MySQLConverterBasezBase class for conversion classes All class dealing with converting to and from MySQL data types must be a subclass of this class. charset use_unicode str_fallbackreturnNct|_d|_d|_d|_d|_|j |||_||_i|_ y)Nr) r_character_set python_types mysql_typesr charset_id set_charsetrr_cache_field_types)selfrrrs K/opt/nydus/tmp/pip-target-a90h98xg/lib/python/mysql/connector/conversion.py__init__zMySQLConverterBase.__init__EsW -9N-1,0&*   !!,".   character_setc|dvrd}|||_nd|_|r||_|jj|jd|_y)zSet character set)utf8mb4utf8mb3utf8Nr)rr"get_charset_infor%)r(rr,s r)r&zMySQLConverterBase.set_charsetXsT , ,G  "DL"DL "/D -->>t||LQOr+valuec||_y)zSet whether to use UnicodeN)rr(r2s r) set_unicodezMySQLConverterBase.set_unicodeis  r+c|jjj} t|d|d|}|S#t$r|cYSwxYw)!Convert Python data type to MySQL_ _to_mysql) __class____name__lowergetattrAttributeErrorr(r2 type_name converteds r)to_mysqlzMySQLConverterBase.to_mysqlms\OO,,224  .Ugda {) A  A vtypec|dk(s||dtjk7ry|js\i|_tjj D]4\}} t |d|j d|j|d<6|y |j|d||S#t$rY_wxYw#t$r|cYSwxYw)!Convert MySQL data type to PythonNr r8 _to_pythonr) rBITr'descitemsr=r<r>KeyError)r(rCr2nameinfos r) to_pythonzMySQLConverterBase.to_pythonzs W  58y}}3L&&&(D #'nn224 d7>$**,z:8D++DG45 = 44**584UEB B & L s$.B$ B3$ B0/B03 CCsql_modec|S)z"Escape buffer for sending to MySQLr2rOs r)escapezMySQLConverterBase.escapes  r+bufct|S)z!Quote buffer for sending to MySQLstrrTs r)quotezMySQLConverterBase.quotes 3xr+)r0TFN)T)r; __module__ __qualname____doc__r rWboolr*rr&r5rr rrBrbytesrrN staticmethodrrSrrYrQr+r)rr>s)"( " #   (OSP}P5=l5KP P"!!! )  #Z/ 0 $-5e_ 4155e,- 3:r+rc eZdZdZ d2deedededdffd Zed3de d ee ee fde fd Z ed ee e eeee fde fd Zdedefd Zdedee defdZededefdZededefdZede dee fdZdede e effdZdede e effdZede de fdZedede fdZededefdZ ed4dZ!ede"jDde fdZ#ede"jHde fdZ%ede"jLde fdZ'ede&jPde fdZ)ede"jTde fdZ+ededee fdZ,de-e d fd!e.ede-ed ffd"Z/ed3de d#eede fd$Z0e0Z1ed3de d#eedefd%Z2e2Z3e2Z4e2Z5e2Z6e2Z7 d3de d#eedefd&Z8e8Z9ed3de d#eedefd'Z:ed3de d(eedefd)Z;e d3de d(eedee"jHfd*Ze d3de d(eedee"jDfd,Z?e?Z@ed3de d(eedefd-ZA d3de d(eedeBefd.ZC d3de d(eede eDeBeffd/ZEeEZFeEZG d3de d(eede eDeBeffd0ZHe d3dee d#eedeeIjfd1ZJeHZKeHZLeHZMxZNS)5MySQLConverteraDefault 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). Nrrrr c6t||||i|_yrZ)superr*r')r(rrrr:s r)r*zMySQLConverter.__init__s# +|<  r+r2rOct|tr|j}t|ttfr|$tj |vr|j ddS|j dd}|j dd}|j dd}|j dd }|j d d }|j d d }|St|trt|ts|$tj |vr|j ddS|j dd}|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\\ s\n s\rs\'"s\"s\'z''\z\\ z\n z\rz\'"z\"z\) isinstancer_decode bytearrayrNO_BACKSLASH_ESCAPESreplacerWrrRs r)rSzMySQLConverter.escapesR h &(H eeY/ 0#(D(D(P}}T511MM%1EMM%0EMM%0EMM';7EMM';7EMM';7E s #Juj,I#(D(D(P}}S$//MM$/EMM$.EMM$.EMM&*5EMM&*5EMM&*5E r+rTct|trt|jdSt|t dr t dSt d|zdzS)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 '' Returns a bytearray object. asciiNsNULLrf)rrrrWencodetypertrXs r)rYzMySQLConverter.quotesN c= )s8??7+ + c4: &W% %d*++r+cttr jtjt d}|sIt fdtjDjjj} t|d|d}|S#t$r8|jrtjcYSt!d|ddwxYw)r7c3@K|]\}}t|r|ywrZ)rr).0 data_typerLr2s r) z*MySQLConverter.to_mysql..s'+T 4!%3+Tsr8r9zPython 'z%' cannot be converted to a MySQL typeN)rrrr2rgetrznextrJr:r;r<r=r>rrWry TypeErrorr?s ` r)rBzMySQLConverter.to_mysqls eT "KKE;>>tE{BO +L+R+R+T ((..0 I +R741YKy9Q+R,I    5z((**9+%JK   s B!!.C"C"rCcN|dk(r|dtjk7ry|y|js\i|_tjj D]4\}} t |d|j d|j|d<6 |j|d||S#t$rY\wxYw#t$r( |jdcYS#t$r|cYcYSwxYwt$r}t|d|dd|d}~wt$r}t|d|dd|d}~wwxYw) rErr Nr8rGutf-8 (field )) rrHr'rIrJr=r<r>rKrsUnicodeDecodeError ValueErrorr)r(rCr2rLrMerrs r)rNzMySQLConverter.to_python sD A:%(imm3 =&&&(D #'nn224 d7>$**,z:8D++DG45 B44**584UEB B &   ||G,,%    CuHU1XJa89s B Bse8E!H:Q78c A BsZ.B" B1" B.-B.1 D$;C D$ CD$C D$)C>> D$ DD$ct|S)zConvert value to intintr2s r) _int_to_mysqlzMySQLConverter._int_to_mysql/s5zr+ct|S)zConvert value to int Note: There is no type "long" in Python 3 since integers are of unlimited size. Since Python 2 is no longer supported, this method should be deprecated. rrs r)_long_to_mysqlzMySQLConverter._long_to_mysql4s5zr+cDtj|ryt|S)zConvert value to floatN)mathisnanfloatrs r)_float_to_mysqlzMySQLConverter._float_to_mysql=s ::e U|r+c$|j|S)zConvert value to string)_unicode_to_mysqlr4s r) _str_to_mysqlzMySQLConverter._str_to_mysqlDs%%e,,r+c|j}|j}|dk(r d}|jj|d}|j |}||jj vrd|vr t ||S|S)zConvert unicodebinaryr0rrg)rr%r"r1ryslash_charsetsr)r(r2rr%encodeds r)rz MySQLConverter._unicode_to_mysqlHsx,,__ h G,,==gFqIJ,,w' ,,;; ;'!!%11r+c|SzConvert value to bytesrQrs r)_bytes_to_mysqlzMySQLConverter._bytes_to_mysqlUs  r+ct|Sr)r_rs r)_bytearray_to_mysqlz"MySQLConverter._bytearray_to_mysqlZsU|r+c|rdSdS)zConvert value to booleanr rrQrs r)_bool_to_mysqlzMySQLConverter._bool_to_mysql_sq q r+cy)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. NrQrs r)_nonetype_to_mysqlz!MySQLConverter._nonetype_to_mysqldsr+c |jrnd}|j|j|j|j|j |j |j|jjdSd}|j|j|j|j|j |j |jjdS)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. z7{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:06d}rxz/{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}) microsecondformatyearmonthdayhourminutesecondry)r2fmts r)_datetime_to_mysqlz!MySQLConverter._datetime_to_mysqlos   KC::      !!fWo @zz JJ KK II JJ LL LL   &/ r+cv|jdd|jdd|jdjdS)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. 04d-02drx)rrrryrs r)_date_to_mysqlzMySQLConverter._date_to_mysqls:**S!5;;s"31UYYsODKKGTTr+c|jr |jdjdS|jdjdS)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.%frxz%H:%M:%S)rstrftimeryrs r)_time_to_mysqlzMySQLConverter._time_to_mysqlsA   >>-077@ @~~j)0099r+cLtjd|jdS)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:%Srx)timerryrs r)_struct_time_to_mysqlz$MySQLConverter._struct_time_to_mysqls!}}0%8??HHr+ct|jdz|jz}|jr3d}|jdkrd|jz }|dz}n|j}nd}|jdkrd|z}t |d\}}t |d \}}|jr|j |||}n|j |||}|j d S) z Converts a timedelta instance to a string suitable for MySQL. The returned string has format: %H:%M:%S Returns a bytes. iQz{0:02d}:{1:02d}:{2:02d}.{3:06d}ri@Br z{0:02d}:{1:02d}:{2:02d}ri<rx)absdaysseconds microsecondsdivmodrry) r2rrmcshours remainderminssecsresults r)_timedelta_to_mysqlz"MySQLConverter._timedelta_to_mysqlsejj5(5==89   3CzzA~ 2 221 ((+C ::>)C#GT2 i, t   ZZtT37FZZtT2F}}W%%r+cXt|trt|jdSy)z Converts a decimal.Decimal instance to a string suitable for MySQL. Returns a bytes or None when not valid. rxN)rrrrWryrs r)_decimal_to_mysqlz MySQLConverter._decimal_to_mysqls& eW %u:$$W- -r+row.fieldscd}dgt|z}|js\i|_tjj D]4\}} t |d|j d|j|d<6|D]O}|d}||dk(r|tjk7s|||dz }. |j||||||<|dz }Qt|S#t$rYwxYw#t$r3 ||jd||<n#t$r ||||<YnwxYwY\ttf$r} | d|dd| _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. rNr8rGr rrr)lenr'rrIrJr=r<r>rHrKrsrrrmessagetuple) r(rrirrLrMfield field_typers r) row_to_pythonzMySQLConverter.row_to_pythonsw ,06CK+?&&&(D #'nn224 d7>$**,z:8D++DG45EqJA! imm ;AQ ?D33J?ANq  FA+.V}7& '' #A g 6F1I)' #AF1I' * !$XeAhZq9  sT .C+C( C%$C%( E2D  E DEDE#E1EErIct|S)z. Returns value as float type. )rr2rIs r)_float_to_pythonzMySQLConverter._float_to_pythons U|r+ct|S)z, Returns value as int type. rrs r)_int_to_pythonzMySQLConverter._int_to_python 5zr+cN|j|j}t|S)z5 Returns value as a decimal.Decimal. )rsrr)r(r2rIvals r)_decimal_to_pythonz!MySQLConverter._decimal_to_python+s ll4<<(s|r+ct|S)z, Returns value as str type. rVrs r)_strzMySQLConverter._str6rr+dscc|}t|dkrddt|z z|z}ttjd|dS)z!Returns BIT columntype as integerrFz>Qr)rrstructunpack)r2rint_vals r)_bit_to_pythonzMySQLConverter._bit_to_python=sH wtE{m1MNTW W Xs  616cd}|j|j}|s tS t|jd}|S#t$r}t dt |d|d}~wwxYw)zReturns 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,zCould not convert set z to a sequence)rsrsetrrr)r(r2rset_typerrs r)_set_to_pythonzMySQLConverter._set_to_pythonsull4<<(5L 399S>*H   (e ^D  sA A.A))A.c|jdk(r|S|o|dtjk(r'|jr|j |jS|dt j zr|j||S|ddk(r|St|ttfr(|jr |j |jS|S#t$r|cYSwxYw)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. rr r?) rrJSONrrsrSETrrrr_rtrr(r2rs r)_string_to_pythonz MySQLConverter._string_to_pythons <<8 #L ?1v'D,<,<||DLL111v %**5#661v| eeY/ 0T5E5E ||DLL11 &   s&C CCc|?|dtjzr)|dtjzr|ddk(r t|S|j ||S)z!Convert BLOB data type to Python.rrr)rBLOBBINARYr_rrs r)_blob_to_pythonzMySQLConverter._blob_to_pythonsS ?A'FY---FbLU|#%%eS11r+c|t|tjr|St|ttfrtjt|St d|j j)z Converts a MySQL VECTOR value to a Python array.array type. Returns an array of floats if `value` isn't `None`, otherwise `None`. zGot unsupported type )rrarrayr_rtrrr:r;rs r)_vector_to_pythonz MySQLConverter._vector_to_pythonsZ =Juekk:L eeY/ 0;;5u= =/0H0H/IJKKr+)NTFrZ)r2Nr N)Or;r[r\r]r rWr^r*r`rr r_rSrrrrrYrrrBrrrNrrrrrrrtrrrrrrrrr struct_timerrrrr rrr_double_to_pythonr_tiny_to_python_short_to_python_int24_to_python_long_to_python_longlong_to_pythonr_newdecimal_to_pythonrrr_NEWDATE_to_pythonrr _timestamp_to_pythonrr rrr_var_string_to_python_json_to_pythonrr r!_long_blob_to_python_medium_blob_to_python_tiny_blob_to_python __classcell__)r:s@r)rbrbs5 "& " #     cXeCJ.?%@C> ,8E%gz5"HIJ ,u , ,27H<#B#B#B  #BJSSccu% -3-5 1B+C- s uUJ5F/G u9!d!s!!("3"3> Uhmm U U U :hmm : : :IT%5%5I%II&8#5#5&%&&@  Xe_  0$0.2?.C0 !3& '0fXo-FRW )e8O+DPS %O%%$O(?C"*?"; /E/!:c 4e4(?*C4s447;#O4 (-- 0)7;!!#O4!   !!F7;,,#O4, (## $,,\/u8O+DPS>B!)/!: S.>B!)/!: z3s8# $6.'O>B 2 2!)/!: 2 z3s8# $ 2BFLL&.&?L %++ LL +,*r+rb)'r]r rrrrdecimalrenumrtypingrrrrr r r r constantsrrrrrr custom_typesrtypesrrrrrutilsrrrrbrQr+r)r9sg:(  III%!@ aaHr +'r +r+