U ¯Dx`3Èã @sšddlZddlZddlZddlZddlZddlZddlZddlmZddl m Z m Z ddl m Z mZmZmZmZddlmZddlmZddlmZdd lmZmZmZmZmZmZdd lmZmZzddl Z d Z!Wne"k rðdZ d Z!YnXzddl#Z#e# $¡Z%[#Wne"e&fk r&dZ%YnXd Z'ej(ej)ej*ej+ej,ej-ej.ej/ej0h Z1d Z2dZ3dd„Z4dd„Z5Gdd„dƒZ6Gdd„dƒZ7Gdd„dƒZ8dS)éNé)Ú_auth)Úcharset_by_nameÚ charset_by_id)ÚCLIENTÚCOMMANDÚCRÚ FIELD_TYPEÚ SERVER_STATUS)Ú converters)ÚCursor)ÚParser)Ú dump_packetÚ MysqlPacketÚFieldDescriptorPacketÚOKPacketWrapperÚEOFPacketWrapperÚLoadLocalPacketWrapper)ÚerrÚVERSION_STRINGTFZutf8mb4éÿÿÿcCst d|¡dd…S)Núd?„Z%dgd@dA„Z&dBdC„Z'e(fdDdE„Z)dFdG„Z*dHdI„Z+dhdJdK„Z,dLdM„Z-dNdO„Z.dPdQ„Z/dRdS„Z0dTdU„Z1dVdW„Z2dXdY„Z3dZd[„Z4d\d]„Z5d^d_„Z6d`da„Z7e8j9Z9e8j:Z:e8j;Z;e8jZ>e8j?Z?e8j@Z@e8jAZAe8jBZBdS)iÚ ConnectionaP Representation of a socket with a mysql server. The proper way to get an instance of this class is to call connect(). Establish a connection to the MySQL database. Accepts several arguments: :param host: Host where the database server is located :param user: Username to log in as :param password: Password to use. :param database: Database to use, None to not use a particular one. :param port: MySQL port to use, default is usually OK. (default: 3306) :param bind_address: When the client has multiple network interfaces, specify the interface from which to connect to the host. Argument can be a hostname or an IP address. :param unix_socket: Optionally, you can use a unix socket rather than TCP/IP. :param read_timeout: The timeout for reading from the connection in seconds (default: None - no timeout) :param write_timeout: The timeout for writing to the connection in seconds (default: None - no timeout) :param charset: Charset you want to use. :param sql_mode: Default SQL_MODE to use. :param read_default_file: Specifies my.cnf file to read these parameters from under the [client] section. :param conv: Conversion dictionary to use instead of the default one. This is used to provide custom marshalling and unmarshalling of types. See converters. :param use_unicode: Whether or not to default to unicode strings. This option defaults to true. :param client_flag: Custom flags to send to MySQL. Find potential values in constants.CLIENT. :param cursorclass: Custom cursor class to use. :param init_command: Initial SQL statement to run when connection is established. :param connect_timeout: Timeout before throwing an exception when connecting. (default: 10, min: 1, max: 31536000) :param ssl: A dict of arguments similar to mysql_ssl_set()'s parameters. :param ssl_ca: Path to the file that contains a PEM-formatted CA certificate :param ssl_cert: Path to the file that contains a PEM-formatted client certificate :param ssl_disabled: A boolean value that disables usage of TLS :param ssl_key: Path to the file that contains a PEM-formatted private key for the client certificate :param ssl_verify_cert: Set to true to check the validity of server certificates :param ssl_verify_identity: Set to true to check the server's identity :param read_default_group: Group to read from in the configuration file. :param autocommit: Autocommit mode. None means use server default. (default: False) :param local_infile: Boolean to enable the use of LOAD DATA LOCAL command. (default: False) :param max_allowed_packet: Max size of packet sent to server in bytes. (default: 16MB) Only used to limit size of "LOAD LOCAL INFILE" data packet smaller than default (16KB). :param defer_connect: Don't explicitly connect on construction - wait for connect call. (default: False) :param auth_plugin_map: A dict of plugin names to a class that processes that plugin. The class will take the Connection object as the argument to the constructor. The class needs an authenticate method taking an authentication packet as an argument. For the dialog plugin, a prompt(echo, prompt) method can be used (if no authenticate method) for returning a string from the user. (experimental) :param server_public_key: SHA256 authentication plugin public key value. (default: None) :param binary_prefix: Add _binary prefix on bytes and bytearray. (default: False) :param compress: Not supported :param named_pipe: Not supported :param db: **DEPRECATED** Alias for database. :param passwd: **DEPRECATED** Alias for password. See `Connection `_ in the specification. NÚFrTé r")&ÚuserÚpasswordÚhostÚdatabaseÚ unix_socketÚportÚcharsetÚsql_modeÚread_default_fileÚconvÚ use_unicodeÚ client_flagÚ cursorclassÚ init_commandÚconnect_timeoutÚread_default_groupÚ autocommitÚ local_infileÚmax_allowed_packetÚ defer_connectÚauth_plugin_mapÚ read_timeoutÚ write_timeoutÚ bind_addressÚ binary_prefixÚ program_nameÚserver_public_keyÚsslÚssl_caÚssl_certÚ ssl_disabledÚssl_keyÚssl_verify_certÚssl_verify_identityÚcompressÚ named_pipeÚpasswdÚdbc&*s¼|&dk r|dkr|&}|%dk r$|s$|%}|#s,|$r4tdƒ‚t|ƒ|_|jrN| tjO} ˆrl| sltj d¡rhd} nd} | r6ˆszd‰tƒ‰ˆ  t j   | ¡¡‡‡fdd„}'|'d|ƒ}|'d |ƒ}|'d |ƒ}|'d |ƒ}|'d |ƒ}t |'d |ƒƒ}|'d|ƒ}|'d|ƒ}|süi}t|tƒr6dD](}(|'d|(| |(¡ƒ})|)r |)||(<q d|_|sÒ|s`|s`| s`|!s`|"r¢|t|"ƒ|!dk rv|!nddœ}|dk r||d<| dk r¢| |d<|rÒts¶tdƒ‚d|_| tjO} | |¡|_|pÚd|_|pæd|_t|jƒt k rtdƒ‚|p t|_|pd|_t|jtƒr6|j d¡|_||_||_ ||_!d|kr`dksjntdƒ‚|prd|_"|dk r’|dkr’td ƒ‚||_#|dk r´|dkr´td!ƒ‚||_$|pÂt%|_&| |_'t(|j&ƒj)|_)| tj*O} |jrö| tj+O} | |_,| |_-d|_.d|_/d"|_0||_1| dkr*t2j3} d#d$„|  4¡Dƒ|_5d%d$„|  4¡Dƒ|_6||_7||_8||_9|pli|_:||_;||_d'œ|_?|r¢||j?d(<|r°d|_@n| A¡dS))Nz3compress and named_pipe arguments are not supportedÚwinz c:\my.iniz /etc/my.cnfÚclientcs4|r|Szˆ ˆ|¡WStk r.|YSXdS©N)ÚgetÚ Exception)ÚkeyÚarg©Úcfgr;rrÚ_configòs z$Connection.__init__.._configr,r-r.r/Úsocketr1z bind-addresszdefault-character-set)ÚcaÚcapathÚcertrWÚcipherzssl-F)r]Úcheck_hostnameÚ verify_moder_rWzssl module not foundTÚ localhostiê zport should be of type intóÚlatin1ri€3áz+connect_timeout should be >0 and <=31536000zread_timeout should be > 0zwrite_timeout should be > 0z Not connectedcSs"i|]\}}t|ƒtk r||“qSr©ÚtypeÚint©Ú.0ÚkÚvrrrÚ Ls z'Connection.__init__..cSs"i|]\}}t|ƒtkr||“qSrrfrirrrrmMs Zpymysql)Z _client_nameZ_pidZ_client_versionrE)BÚNotImplementedErrorÚboolÚ _local_infilerZ LOCAL_FILESÚsysÚplatformÚ startswithr ÚreadÚosÚpathÚ expanduserrhÚ isinstanceÚdictrUrGÚ SSL_ENABLEDÚSSLÚ_create_ssl_ctxÚctxr.r1rgr%Ú DEFAULT_USERr,r-ÚstrÚencoderQr0rCr:Ú _read_timeoutÚ_write_timeoutÚDEFAULT_CHARSETr2r6rÚencodingZ CAPABILITIESÚCONNECT_WITH_DBr7r8Ú_resultÚ_affected_rowsÚ host_infoÚautocommit_moder Z conversionsÚitemsÚencodersÚdecodersr3r9r>Ú_auth_plugin_mapÚ_binary_prefixrFÚgetpidrÚ_connect_attrsÚ_sockÚconnect)*Úselfr,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrErFrGrHrIrJrKrLrMrNrOrPrQr[rWÚvaluerrYrÚ__init__¥sÔ* ÿ            ÿû               ý zConnection.__init__cCs|SrTr©r“rrrÚ __enter__cszConnection.__enter__cGs~| ¡dSrT)Úclose)r“Úexc_inforrrÚ__exit__fszConnection.__exit__cCsRt|tjƒr|S| d¡}| d¡}|dko2|dk}tj||d}| oR| dd¡|_| d¡}|dkr||rrtjntj|_nxt|t ƒrš|rtjntj|_nZt|t ƒr¬|  ¡}|dkr¾tj|_n6|dkrÐtj |_n$|d krâtj|_n|rìtjntj|_d |kr|j |d | d ¡d d |kr.| |d ¡|jtjO_|jtjO_|S)Nr]r^)Úcafiler^raTrb)ÚnoneÚ0ÚfalseÚnoÚoptional)ÚrequiredÚ1ÚtrueÚyesr_rW)Úkeyfiler`)rxrGÚ SSLContextrUÚcreate_default_contextraÚ CERT_NONEÚ CERT_REQUIREDrbrorÚlowerÚ CERT_OPTIONALÚload_cert_chainÚ set_ciphersÚoptionsÚ OP_NO_SSLv2Ú OP_NO_SSLv3)r“Zsslpr]r^Zhasnocar}Zverify_mode_valuerrrr|js8           zConnection._create_ssl_ctxcCsl|jrt d¡‚d|_|jdkr$dSt ddtj¡}z(z|  |¡Wnt k rXYnXW5| ¡XdS)z÷ Send the quit message and close the socket. See `Connection.close() `_ in the specification. :raise Error: If the connection is already closed. úAlready closedTNú`_ in the specification. ZCOMMITNrÉr–rrrÚcommitÎszConnection.commitcCs| tjd¡| ¡dS)z­ Roll back the current transaction. See `Connection.rollback() `_ in the specification. ZROLLBACKNrÉr–rrrÚrollbackØszConnection.rollbackcCs$| tjd¡t|ƒ}| ¡|jS)z%Send the "SHOW WARNINGS" SQL command.z SHOW WARNINGS)rÅrrÆÚ MySQLResultrtÚrows)r“ÚresultrrrÚ show_warningsâszConnection.show_warningscCs| tj|¡| ¡dS)zI Set current db. :param db: The name of the db. N)rÅrZ COM_INIT_DBrÄ)r“rQrrrÚ select_dbészConnection.select_dbcCsXt|tƒrd| |¡dSt|ttfƒrF| |¡}|jrBd|}|Stj||j |dS)z}Escape whatever value you pass to it. Non-standard, for internal use; do not use this in your applications. ú'Ú_binary)Úmapping) rxrÚ escape_stringr&Ú bytearrayÚ _quote_bytesrŽr Z escape_itemr2)r“ÚobjrÔÚretrrrrÇòs  zConnection.escapecCs| ||j¡S)zjAlias for escape() Non-standard, for internal use; do not use this in your applications. )rÇr‹)r“rØrrrÚliteralszConnection.literalcCs"|jtj@r| dd¡St |¡S)NrÒz'')r½r Ú"SERVER_STATUS_NO_BACKSLASH_ESCAPESÚreplacer rÕ©r“ÚsrrrrÕs  zConnection.escape_stringcCs0|jtj@r&d| dd¡ dd¡fSt |¡S)Nz'%s'ó's''ÚasciiÚsurrogateescape)r½r rÛrÜÚdecoder Z escape_bytesrÝrrrr× s zConnection._quote_bytescCs|r ||ƒS| |¡S)a  Create a new cursor to execute queries with. :param cursor: The type of cursor to create; one of :py:class:`Cursor`, :py:class:`SSCursor`, :py:class:`DictCursor`, or :py:class:`SSDictCursor`. None means use Cursor. )r8)r“ÚcursorrrrrãszConnection.cursorcCs:t|tƒr| |jd¡}| tj|¡|j|d|_|jS)Nrá©Ú unbuffered) rxrr€r„rÅrrÆÚ_read_query_resultr‡)r“ÚsqlrårrrÚquerys  zConnection.querycCs|j|d|_|jS)Nrä)rær‡)r“rårrrÚ next_result'szConnection.next_resultcCs|jSrT)r‡r–rrrÚ affected_rows+szConnection.affected_rowscCs"t d|¡}| tj|¡| ¡S)Nr)rrrÅrZCOM_PROCESS_KILLrÄ)r“Ú thread_idrXrrrÚkill.s zConnection.killcCst|jdkr&|r| ¡d}n t d¡‚z| tjd¡| ¡Wn.tk rn|rh| ¡|  d¡n‚YnXdS)z¹ Check if the server is alive. :param reconnect: If the connection is closed, reconnect. :raise Error: If the connection is closed and reconnect=False. NFr±r*) r‘r’rr´rÅrZCOM_PINGrÄrVÚping)r“Z reconnectrrrrí3s    zConnection.pingcCs:t|ƒj}| tjd| |¡¡| ¡||_||_dS)Nz SET NAMES %s)rr„rÅrrÆrÇr¿r2)r“r2r„rrrÚ set_charsetJs  zConnection.set_charsetc Cs`d|_z´|dkr&|jr\t tjtj¡}| |j¡| |j¡d|_d|_ t rZt dƒnÀi}|j dk rx|j df|d<z"tj |j|jf|jf|Ž}WqÚWqxttfk rÖ}z|jtjkrÄWY¢qx‚W5d}~XYqxXqxd|j|jf|_t røt dƒ| tjtjd ¡| tjtjd ¡| d¡||_| d ¡|_d|_| ¡| ¡|jdk rr|  ¡}| !d |jf¡|j"dk r¢|  ¡}| !|j"¡| #¡| $¡|j%dk rº| &|j%¡Wnžt'k rZ}z~d|_|dk rúz | #¡Wn YnXt(|tttj)fƒrHt* +d d |j|f¡}||_,t- .¡|_-t rDt |j-ƒ|‚‚W5d}~XYnXdS)NFzLocalhost via UNIX socketTzconnected using unix_socketrÚsource_addressz socket %s:%dzconnected using socketrÚrbzSET sql_mode=%siÓz(Can't connect to MySQL server on %r (%s))/r³r0r\ÚAF_UNIXÚ SOCK_STREAMÚ settimeoutr:r’rˆÚ_secureÚDEBUGÚprintrCÚcreate_connectionr.r1ÚOSErrorÚIOErrorÚerrnoÚEINTRÚ setsockoptÚ IPPROTO_TCPÚ TCP_NODELAYÚ SOL_SOCKETÚ SO_KEEPALIVEr‘Úmakefiler¹Ú _next_seq_idÚ_get_server_informationÚ_request_authenticationr3rãÚexecuter9r˜rËr‰r<Ú BaseExceptionrxÚerrorrrÁZoriginal_exceptionÚ tracebackÚ format_exc)r“ÚsockÚkwargsÚeÚcÚexcrrrr’Ss‚      ÿÿ          ÿ  zConnection.connectcCsFtt|ƒƒt|jgƒ|}tr(t|ƒ| |¡|jdd|_dS)zvWrites an entire "mysql packet" in its entirety to the network adding its length and sequence number. réN)rÚlenr&rrõrr¶)r“ÚpayloadÚdatarrrÚ write_packetŸs  zConnection.write_packetc Csðtƒ}| d¡}t d|¡\}}}||d>}||jkrj| ¡|dkrVt tj d¡‚t  d||jf¡‚|jdd|_| |¡}t rt |ƒ||7}|d kr¢q|t krq®q|t|ƒ|jƒ} |  ¡rì|jd k rä|jjd kräd |j_|  ¡| S) a!Read an entire "mysql packet" in its entirety from the network and return a MysqlPacket type that represents the results. :raise OperationalError: If the connection to the MySQL server is lost. :raise InternalError: If the packet sequence number is wrong. éz   þÿÿ zConnection._read_packetc Cs¾|j |j¡z|j |¡}Wq˜Wqttfk rx}z4|jtjkrLWY¢"q|  ¡t   t j d|f¡‚W5d}~XYqtk r”|  ¡‚YqXqt|ƒ|krº|  ¡t   t j d¡‚|S)Nz1Lost connection to MySQL server during query (%s)r)r‘rórr¹rtrùrørúrûrµrrÁrrrr)r“Ú num_bytesrr rrrrØs,  þ  ÿzConnection._read_bytesc Csb|j |j¡z|j |¡Wn>tk r\}z | ¡t tj d|f¡‚W5d}~XYnXdS)NzMySQL server has gone away (%r)) r‘rór‚ÚsendallrùrµrrÁrZCR_SERVER_GONE_ERROR)r“rr rrrr¶ñsÿzConnection._write_bytescCsjd|_|rs´   ÿ             ÿþ     ÿz"Connection._request_authenticationc Cs.| |¡}|rPz | |¡WStk rN|dkrJt dd|t|ƒf¡‚YnX|dkrdt ||¡S|dkrxt ||¡S|dkr–t  |j |  ¡¡}nz|dkr´t  |j |  ¡¡}n\|dkrÖt  |j |  ¡¡d }n:|d krì|j d }n$|dkr|}| ¡}|d @d k}|d @d k}|  ¡} | dkr>| |j d ¡n–|rÀd} z| || ¡} | | d ¡WnVtk rt dd||f¡‚Yn.tk r¼t dd||| | f¡‚YnXnt dd||f¡‚| ¡}| ¡| ¡sü|rúqüqú|St dd|¡‚| |¡| ¡}| ¡|S)Nsdialogé zGAuthentication plugin '%s' not loaded: - %r missing authenticate methodr2r3r1sclient_ed25519smysql_old_passwordr0smysql_clear_passwordéérs Password: z3no response - TypeError within plugin.prompt methodzAAuthentication plugin '%s' not loaded: - %r missing prompt methodi zTAuthentication plugin '%s' %r didn't respond with string. Returned '%r' to prompt %rz.Authentication plugin '%s' (%r) not configuredz)Authentication plugin '%s' not configured)Ú_get_auth_plugin_handlerZ authenticateÚAttributeErrorrrÁrgrrDrEr=r-Zread_allZed25519_passwordrCr@rÚpromptÚ TypeErrorr¿Z check_errorrÀ) r“rFrGÚhandlerrrÂÚflagZechoÚlastrMÚresprrrrB¯s’   þþ   ÿÿ     þþ þþ ÿþÿ zConnection._process_authc Csp|j |¡}|s,t|tƒr,|j | d¡¡}|rhz ||ƒ}Wqltk rdt dd||f¡‚YqlXnd}|S)NràrHzXAuthentication plugin '%s' not loaded: - %r cannot be constructed with connection object)rrUrxr&rârNrrÁ)r“rFZ plugin_classrOrrrrKþs  þþ z#Connection._get_auth_plugin_handlercCs |jdSr#)Úserver_thread_idr–rrrrëszConnection.thread_idcCs|jSrT)r2r–rrrÚcharacter_set_nameszConnection.character_set_namecCs|jSrT)rˆr–rrrÚ get_host_infoszConnection.get_host_infocCs|jSrT)Úprotocol_versionr–rrrÚget_proto_infoszConnection.get_proto_infoc Cs d}| ¡}| ¡}|||_|d7}| d|¡}|||… d¡|_|d}t d|||d…¡|_|d7}|||d…|_ |d7}t d |||d …¡d|_ |d 7}t |ƒ|d krft d |||d …¡\}}}}|d 7}||_ zt |ƒj|_Wntk rd|_YnX||_tr6td |ƒ|j |d>O_ trXtd|ƒtd|dƒ}|d7}t |ƒ||kr¢|j ||||…7_ ||7}|d7}|j tj@rt |ƒ|kr| d|¡}|dkrò||d… d¡|_n|||… d¡|_dS)Nrrr0rerréé r!rJrIzr:rZserver_languagerÚnameZserver_charsetÚKeyErrorr½rõröÚmaxrr?r<) r“r'rrZ server_endÚlangÚstatZcap_hZsalt_lenrrrrsN        z"Connection._get_server_informationcCs|jSrT)r7r–rrrÚget_server_info^szConnection.get_server_info)N)N)F)F)T)N)F)CÚ__name__Ú __module__Ú __qualname__Ú__doc__r‘r<r³rôr r•r—ršr|r˜Úpropertyr¸rµÚ__del__r<rºrÄr»rÊrËrÌrÐrÑrÇrÚrÕr×rãrèrérêrìrírîr’rrr¿rr¶rær$rÅrrBrKrërTrUrWrrarÚWarningr´r%Z DatabaseErrorZ DataErrorrÁZIntegrityErrorrZProgrammingErrorZNotSupportedErrorrrrrr)\sÈCØ ?         L - +qOAr)c@steZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„ZdS)rÍcCsF||_d|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ dS)z. :type connection: Connection NrF) r"rêr$r½Ú warning_countÚmessageÚ field_countÚ descriptionrÎr)r)r“r"rrrr•nszMySQLResult.__init__cCs|jr| ¡dSrT)rr(r–rrrrg~szMySQLResult.__del__cCsNz@|j ¡}| ¡r | |¡n| ¡r4| |¡n | |¡W5d|_XdSrT)r"r¿rÀrÄÚis_load_local_packetÚ_read_load_local_packetÚ_read_result_packet©r“Ú first_packetrrrrt‚s   zMySQLResult.readcCsld|_|j ¡}| ¡r0| |¡d|_d|_n8| ¡rP| |¡d|_d|_n| ¡|_|  ¡d|_ dS)zw :raise OperationalError: If the connection to the MySQL server is lost. :raise InternalError: TFNlÿÿÿÿ) rr"r¿rÀrÄrmrnÚread_length_encoded_integerrkÚ_get_descriptionsrêrprrrr!s    z!MySQLResult.init_unbuffered_querycCs<t|ƒ}|j|_|j|_|j|_|j|_|j|_|j|_dSrT)rrêr$r½rirjr))r“rqÚ ok_packetrrrrĨszMySQLResult._read_ok_packetcCsx|jjstdƒ‚t|ƒ}t|j|jƒ}z | ¡Wn|j ¡‚YnX|j ¡}| ¡sjt   dd¡‚|  |¡dS)NzF**WARN**: Received LOAD_LOCAL packet but local_infile option is false.r¾zCommands Out of Sync) r"rpÚ RuntimeErrorrÚ LoadLocalFileÚfilenamer·r¿rÀrrÁrÄ)r“rqZ load_packetÚsenderrtrrrrn±s ÿ   ÿ z#MySQLResult._read_load_local_packetcCs(| ¡s dSt|ƒ}|j|_|j|_dS)NFT)Ú is_eof_packetrrir))r“rZwprrrÚ_check_packet_is_eofÅs z MySQLResult._check_packet_is_eofcCs| ¡|_| ¡| ¡dSrT)rrrkrsÚ_read_rowdata_packetrprrrroÑs zMySQLResult._read_result_packetcCsP|js dS|j ¡}| |¡r4d|_d|_d|_dS| |¡}d|_|f|_|S)NFr)rr"r¿rzrÎÚ_read_row_from_packetrê)r“rÚrowrrrÚ_read_rowdata_packet_unbufferedÖs   z+MySQLResult._read_rowdata_packet_unbufferedcCs,|jr(|j ¡}| |¡rd|_d|_qdSr )rr"r¿rz)r“rrrrr(ès   z$MySQLResult._finish_unbuffered_querycCsJg}|j ¡}| |¡r d|_q2| | |¡¡qt|ƒ|_t|ƒ|_dS)z:Read a rowdata packet for each data row in the result set.N) r"r¿rzÚappendr|rrêÚtuplerÎ)r“rÎrrrrr{òs   z MySQLResult._read_rowdata_packetc Cs†g}|jD]r\}}z | ¡}Wntk r8Yq~YnX|dk rr|dk rT| |¡}trbtd|ƒ|dk rr||ƒ}| |¡q t|ƒS)NzDEBUG: DATA = )r Zread_length_coded_stringÚ IndexErrorrârõrörr€)r“rr}r„Ú converterrrrrr|ÿs     z!MySQLResult._read_row_from_packetc Csg|_g|_|jj}|jj}g}t|jƒD]°}|j t¡}|j  |¡|  |  ¡¡|j }|r’|t j krn|}q–|tkrŒ|jdkr†d}q|}q–d}nd}|jj |¡}|tjkr²d}trÊtd|›d|›ƒ|j  ||f¡q*|j ¡} |  ¡sötdƒ‚t|ƒ|_ dS)z>Read a column descriptor packet for each column in the result.é?Nràz DEBUG: field=z , converter=zProtocol error, expecting EOF)Úfieldsr r"r6r„Úrangerkr¿rrrlZ type_coder ZJSONÚ TEXT_TYPESZ charsetnrrŒrUZthroughrõröryÚAssertionErrorr€) r“r6Z conn_encodingrlr'ÚfieldZ field_typer„r‚Z eof_packetrrrrss8      zMySQLResult._get_descriptionsN)rbrcrdr•rgrtr!rÄrnrzror~r(r{r|rsrrrrrÍms     rÍc@seZdZdd„Zdd„ZdS)rvcCs||_||_dSrT)rwr")r“rwr"rrrr•?szLoadLocalFile.__init__c Cs |jjst dd¡‚|j}ztzDt|jdƒ.}t|jdƒ}|  |¡}|sHqT| |¡q8W5QRXWn*t k rŠt  dd|j›d¡‚YnXW5| d¡Xd S) z3Send data packets from the local file to the serverrr*rdrði@iùzCan't find file 'rÒN) r"r‘rr%rr¸rwr*r>rtrùrÁ)r“ÚconnÚ open_filer,Úchunkrrrr·Cs  ÿ  zLoadLocalFile.send_dataN)rbrcrdr•r·rrrrrv>srv)9rúrur\rrqrr&r*rr2rrÚ constantsrrrr r r Zcursorsr Z optionfiler ÚprotocolrrrrrrrrrGrzÚ ImportErrorÚgetpassÚgetuserr~r]rõZBITZBLOBZ LONG_BLOBZ MEDIUM_BLOBÚSTRINGZ TINY_BLOBZ VAR_STRINGZVARCHARZGEOMETRYr†rƒrrr(r)rÍrvrrrrÚsj       ÷ R