U Yzf_Ϋ@sdZddlmZddlZddlZddlZddlZddlmZddl m Z m Z m Z ddl mZmZmZmZmZmZddlmZmZdd lmZdd lmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#dd l$m%Z%m&Z&dd l'm(Z(dd l)m*Z*m+Z+ddl,m-Z-Gddde-Z.dS)z/Implementing communication with MySQL servers. )IOBaseN)get_auth_plugin)PY2isstr UNICODE_TYPES) ClientFlag ServerCmd ServerFlag flag_is_set ShutdownTypeNET_BUFFER_LENGTH)errorsversion)MySQLConverter) CursorBase MySQLCursorMySQLCursorRawMySQLCursorBufferedMySQLCursorBufferedRawMySQLCursorPreparedMySQLCursorDictMySQLCursorBufferedDictMySQLCursorNamedTupleMySQLCursorBufferedNamedTuple)MySQLUnixSocketMySQLTCPSocket) MySQLProtocol) int4storelinux_distribution)MySQLConnectionAbstractcseZdZdZfddZddZddZdsd d Zdtd dZduddZ ddZ ddZ ddZ e Z dvddZdwddZddZedd Zd!d"Zd#d$Zd%d&Zd'd(Zdxd)d*Zdyd+d,Zd-d.Zd/d0Zdzd1d2Zd3d4Zd5d6Zd7d8Zd{d9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#d|dDdEZ$edFdGZ%e%j&dHdGZ%dIdJZ'd}dKdLZ(d~dNdOZ)ddPdQZ*edRdSZ+ddTdUZ,dVdWZ-dXdYZ.dZd[Z/d\d]Z0d^d_Z1d`daZ2ddbdcZ3dddeZ4ddgdhZ5didjZ6dkdlZ7dmdnZ8dodpZ9dqdrZ:Z;S)MySQLConnectionzConnection to a MySQL Servercsd|_d|_d|_tt|j||t|_t |_ d|_ d|_ d|_ d|_d|_d|_d|_d|_d|_d|_d|_d|_i|_d|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_!d|_"d|_#d|_$g|_%|r z|j&f|Wn|'d|_YnXdS)N-Fz 127.0.0.1i rT)( _protocol_socket _handshakesuperr!__init__r_converter_classrZ get_default _client_flags _charset_idZ _sql_modeZ _time_zoneZ _autocommit_user _password _databaseZ_hostZ_portZ _unix_socketZ _client_hostZ _client_port_ssl _force_ipv6Z _use_unicodeZ _get_warningsZ_raise_on_warnings _bufferedZ_unread_result_have_next_result_raw_in_transactionZ_prepared_statements _ssl_active _auth_pluginZ_pool_config_version _columns_descconnectclose)selfargskwargs __class__r/private/var/folders/n9/53xbvtmd7sjg1q1l55xmpg58n4mgng/T/pip-unpacked-wheel-47tvuv7y/mysql/connector/connection.pyr(<sP zMySQLConnection.__init__c CstjdkrRdtdkr d}ndtdkr6d}nt}dtd}n>t}td kr|d d td}nd t dd }t j d}|ddkrd}nd}tt|td|d ddt jddD|d}|j|dS)z&Add the default connection attributes.ntZ64rx86_64Z32i386z Windows-{}rDarwinz{}-{}macOS- ZGPLv2zGPL-2.0Z Commercialzmysql-connector-python.cSsg|] }t|qSr?)str).0xr?r?r@ sz;MySQLConnection._add_default_conn_attrs..)Z_pid _platformZ _source_hostZ _client_nameZ_client_licenseZ_client_version_osN)osnameplatform architectureformat win32_vermachinesystemmac_verjoinrrLICENSEsplitrJgetpidsocket gethostnameVERSION _conn_attrsupdate)r:Z platform_archZos_verZlicense_chunksZclient_licenseZdefault_conn_attrsr?r?r@_add_default_conn_attrsos0      z'MySQLConnection._add_default_conn_attrsc Cs|j}|ddkr t|d|_z|j|}Wn8tk rn}ztj|j |j |j dW5d}~XYnX| |d|_ |dtj@s|jtjM_|jdrtjdd d n|js|jtjO_|dtj@r|tjg||_dS) z'Get the handshake from the MySQL serverN)msgerrnosqlstateZserver_version_originalZ capabilities verify_certz1SSL is required but the server doesn't support iti)rg)r%recvr get_exceptionr&r$Zparse_handshake ExceptionZget_mysql_exceptionrfrgrhZ_check_server_version_server_versionrSSLr*r/getInterfaceErrorZ _ssl_disabledZ PLUGIN_AUTHZset_client_flags)r:packet handshakeerrr?r?r@ _do_handshakes0     zMySQLConnection._do_handshakeNrr"c Csd|_|tj@r|jj||d}|j||ddk rLd|d} nd} |j |d|d|d |d pzd|d pd| |d d |_|jj |j ||||||j|j |d }|j|| |||tj@s|r||d S)aeAuthenticate with the MySQL server Authentication happens in two parts. We first send a response to the handshake. The MySQL server will then send either an AuthSwitchRequest or an error packet. Raises NotSupportedError when we get the old, insecure password reply back. Raises any error coming from MySQL. F)charset client_flagstls_ciphersuitesN:r#cacertkeyriZverify_identityZ tls_versionsT) rrusernamepassworddatabaserurv ssl_enabled auth_plugin conn_attrs)r5rrnr$Z make_auth_sslr%sendrorZZ switch_to_sslZ make_authr&r6_auth_switch_requestCONNECT_WITH_DB cmd_init_db) r:r|r}r~rvruZ ssl_optionsrrqrwr?r?r@_do_authsF        zMySQLConnection._do_authcCsd}|jp|jd}|j}|ddkrBt|dkrBtdnN|ddkr|j|\}}t ||||j d}| }|j ||j}|ddkr|j |}t ||||j d}|d kr| }|r|j ||j}|dd kr||S|dd krt|dS) zHandle second part of authentication Raises NotSupportedError when we get the old, insecure password reply back. Raises any error coming from MySQL. NrrdzAuthentication with old (insecure) passwords is not supported. For more information, lookup Password Hashing in the latest MySQL manual)r}rrZcaching_sha2_passwordrre)r6r&r%rjlenrNotSupportedErrorr$Zparse_auth_switch_requestrr5Z auth_responserZparse_auth_more_data _handle_okrk)r:r|r}authZnew_auth_pluginrqZ auth_dataresponser?r?r@rsH            z$MySQLConnection._auth_switch_requestcCsFd}|jr"tjdkr"t|jd}nt|j|j|jd}||j |S)zGet connection based on configuration This method will return the appropriated connection object using the connection parameters. Returns subclass of MySQLBaseSocket. NrA) unix_socket)hostportZ force_ipv6) rrQrRrrZ server_hostZ server_portr0set_connection_timeoutZ_connection_timeout)r:Zprtclsconnr?r?r@_get_connections zMySQLConnection._get_connectionc Cst|_||_zv|j|||j|j|j |j |j |j |j ||j|j tj@rz|jj|j_|jj|j_|jdWn|YnXdS)zOpen the connection to the MySQL server This method sets up and opens the connection to the MySQL server. Raises on errors. N)rr$rr%Zopen_connectionrtrr,r-r.r*r+r/raZset_converter_classr)rZCOMPRESSZrecv_compressedrjZsend_compressedrrr9r:r?r?r@_open_connections(       z MySQLConnection._open_connectionc Cs8|js dSz|jWnttjfk r2YnXdS)z.Shut down connection to MySQL Server. N)r%shutdownAttributeErrorrErrorrr?r?r@r/s zMySQLConnection.shutdownc Cs@|js dSz |Wnttjfk r0YnX|jdS)z Disconnect from the MySQL serverN)r%cmd_quitrrrZclose_connectionrr?r?r@r9:s zMySQLConnection.closeTcCs\|z"|j|j||p|||Wntk rHtdYnX|sRdS|jS)a4Send a command to the MySQL server This method sends a command with an optional argument. If packet is not None, it will be sent and the argument will be ignored. The packet_number is optional and should usually not be used. Some commands might not result in the MySQL server returning a response. If a command does not return anything, you should set expect_response to False. The _send_cmd method will then return None instead of a MySQL packet. Returns a MySQL packet or None. MySQL Connection not available.N) handle_unread_resultr%rr$ make_commandrrOperationalErrorrj)r:commandZargumentZ packet_numberrqexpect_responseZcompressed_packet_numberr?r?r@ _send_cmdGszMySQLConnection._send_cmdFcCs|t|dstdz2|td}|rJ|j||td}q*Wntk rjt dYnX|rz|jdWntk rt dYnX|j S)a4Send data to the MySQL server This method accepts a file-like object and sends its data as is to the MySQL server. If the send_empty_packet is True, it will send an extra empty package (for example when using LOAD LOCAL DATA INFILE). Returns a MySQL packet. readzexpecting a file-like objectr) rhasattr ValueErrorrr r%rrrrrj)r: data_filesend_empty_packetbufr?r?r@ _send_dataes$    zMySQLConnection._send_datacCs ttj||_ttj||_dS)aHandle the server flags found in MySQL packets This method handles the server flags send by MySQL OK and EOF packets. It, for example, checks whether there exists more result sets or whether there is an ongoing transaction. N)r r ZMORE_RESULTS_EXISTSr2ZSTATUS_IN_TRANSr4)r:flagsr?r?r@_handle_server_statussz%MySQLConnection._handle_server_statuscCs|jS)z'MySQL session has started a transaction)r4rr?r?r@in_transactionszMySQLConnection.in_transactioncCsN|ddkr*|j|}||d|S|ddkr@t|tddS)aHandle a MySQL OK packet This method handles a MySQL OK packet. When the packet is found to be an Error packet, an error will be raised. If the packet is neither an OK or an Error packet, errors.InterfaceError will be raised. Returns a dict() rdr status_flagrezExpected OK packetN)r$Zparse_okrrrkrp)r:rqZok_pktr?r?r@rs    zMySQLConnection._handle_okcCsN|ddkr*|j|}||d|S|ddkr@t|tddS)a Handle a MySQL EOF packet This method handles a MySQL EOF packet. When the packet is found to be an Error packet, an error will be raised. If the packet is neither and OK or an Error packet, errors.InterfaceError will be raised. Returns a dict() rdrrrezExpected EOF packetN)r$Z parse_eofrrrkrp)r:rqeofr?r?r@ _handle_eofs    zMySQLConnection._handle_eofcCsz~z$t|d}||j|ddWWZStk rzz|jdWntk rdt dYnXt d |YnXW5z |Wnttfk rYnXXdS)z'Handle a LOAD DATA INFILE LOCAL requestrbT)rrrzFile '{0}' could not be readN) r9IOError NameErroropenrrr%rrrrrprU)r:filenamerr?r?r@_handle_load_data_infiles&    z(MySQLConnection._handle_load_data_infilecCs|rt|dkrtdn~|ddkr2||S|ddkrntrTt|dd}n|dd}||S|ddkr||S|ddkrt ||j |}|rt |t std dg||_td|D] }|j |j|j|j|<q||j}d |_|j|d S) aHandle a MySQL Result This method handles a MySQL result, for example, after sending the query command. OK and EOF packets will be handled and returned. If the packet is an Error packet, an errors.Error-exception will be raised. The dictionary returned of: - columns: column information - eof: the EOF-packet information Returns a dict() rdEmpty responserrNrreIllegal result set.T)columnsr)rrrprrrJdecoderrrkr$parse_column_count isinstanceintr7range parse_columnr%rjpython_charset unread_result)r:rqr column_countirr?r?r@_handle_results2             zMySQLConnection._handle_resultcCs.|jd|||d\}}|r&|d|fSd|fS)aTGet the next rows returned by the MySQL server This method gets one row from the result set after sending, for example, the query command. The result is a tuple consisting of the row and the EOF packet. If no row was available in the result set, the row data will be None. Returns a tuple. r)countbinaryrrawrN)get_rows)r:rrrrowsrr?r?r@get_rows   zMySQLConnection.get_rowc s|dkrj}jstdzF|rLj}|dkr6d}jj|||}njjjj |d}Wn.tj k r}zd_|W5d}~XYnX|\}} |s|s؈j dk r|rt dr؈j jfdd |D}| dk rd | kr| d n| d d_|| fS) aGet all rows returned by the MySQL server This method gets all rows returned by the MySQL server after sending, for example, the query command. The result is a tuple consisting of a list of rows and the EOF packet. Returns a tuple() NzNo result set available.Zutf8mb4utf8)rF convertercsg|]}|jqSr?)r7)rKrow row_to_pythonr:r?r@rM+sz,MySQLConnection.get_rows..rZ server_status)r3rr InternalErrorrur$Zread_binary_resultr%Zread_text_resultrmrr7rrrr) r:rrrrZ prep_stmtrurrsZeof_pr?rr@rsH      zMySQLConnection.get_rowscCs|jr|dS)zConsume results N)rrrr?r?r@consume_results4szMySQLConnection.consume_resultscCs||tj|dS)zChange the current database This method changes the current (default) database by sending the INIT_DB command. The result is a dictionary containing the OK packet information. Returns a dict() utf-8)rrr ZINIT_DBencode)r:r~r?r?r@r:s zMySQLConnection.cmd_init_dbcCs<t|ts|d}||tj|}|jr8t d|S)a Send a query to the MySQL server This method send the query to the MySQL server and returns the result. If there was a text result, a tuple will be returned consisting of the number of columns and a list containing information about these columns. When the query doesn't return a text result, the OK or EOF packet information as dictionary will be returned. In case the result was an error, exception errors.Error will be raised. Returns a tuple() rz8Use cmd_query_iter for statements with multiple queries.) rbytesrrrr QUERYr2rrp)r:queryrbufferedZ raw_as_stringresultr?r?r@ cmd_queryFs  zMySQLConnection.cmd_queryccsjt|ts.t|r&t|tr&|d}t|}||tj|V|j rf| ||j VqDdS)atSend one or more statements to the MySQL server Similar to the cmd_query method, but instead returns a generator object to iterate through results. It sends the statements to the MySQL server and through the iterator you can get the results. statement = 'SELECT 1; INSERT INTO t1 VALUES (); SELECT 2' for result in cnx.cmd_query(statement, iterate=True): if 'columns' in result: columns = result['columns'] rows = cnx.get_rows() else: # do something useful with INSERT result Returns a generator. rN) r bytearrayrrrrrr rr2rr%rj)r:Z statementsr?r?r@cmd_query_iter_s  zMySQLConnection.cmd_query_itercCs||tjt|S)aSend the Refresh command to the MySQL server This method sends the Refresh command to the MySQL server. The options argument should be a bitwise value using constants.RefreshOption. Usage example: RefreshOption = mysql.connector.RefreshOption refresh = RefreshOption.LOG | RefreshOption.THREADS cnx.cmd_refresh(refresh) The result is a dictionary with the OK packet information. Returns a dict() )rrr ZREFRESHr)r:optionsr?r?r@ cmd_refresh}szMySQLConnection.cmd_refreshcCs*||jtj}|j|dd|S)aClose the current connection with the server This method sends the QUIT command to the MySQL server, closing the current connection. Since the no response can be returned to the client, cmd_quit() will return the packet it send. Returns a str() r)rr$rr ZQUITr%rr:rqr?r?r@rs zMySQLConnection.cmd_quitcCs<|rt|std|}ntj}||tjt |S)aZShut down the MySQL Server This method sends the SHUTDOWN command to the MySQL server and is only possible if the current user has SUPER privileges. The result is a dictionary containing the OK packet information. Note: Most applications and scripts do not the SUPER privilege. Returns a dict() zInvalid shutdown type) r get_inforrpZSHUTDOWN_DEFAULTrrr ZSHUTDOWNr)r:Z shutdown_typeatyper?r?r@ cmd_shutdowns    zMySQLConnection.cmd_shutdowncCs8||jtj}|j|dd|j|jS)zSend the statistics command to the MySQL Server This method sends the STATISTICS command to the MySQL server. The result is a dictionary with various statistical information. Returns a dict() r) rr$rr Z STATISTICSr%rZparse_statisticsrjrr?r?r@cmd_statisticsszMySQLConnection.cmd_statisticscCs||tjt|S)zKill a MySQL process This method send the PROCESS_KILL command to the server along with the process ID. The result is a dictionary with the OK packet information. Returns a dict() )rrr Z PROCESS_KILLr)r:Z mysql_pidr?r?r@cmd_process_kills z MySQLConnection.cmd_process_killcCs||tjS)aFSend the DEBUG command This method sends the DEBUG command to the MySQL server, which requires the MySQL user to have SUPER privilege. The output will go to the MySQL server error log and the result of this method is a dictionary with EOF packet information. Returns a dict() )rrr DEBUGrr?r?r@ cmd_debugs zMySQLConnection.cmd_debugcCs||tjS)aSend the PING command This method sends the PING command to the MySQL server. It is used to check if the the connection is still valid. The result of this method is dictionary with OK packet information. Returns a dict() )rrr ZPINGrr?r?r@cmd_pings zMySQLConnection.cmd_pingr#c Cs||jrtd|jj|j|||||j|j|j d}|j |dd| ||}z|jt j@st|rt||WnYnX||_||S)zChange the current logged in user This method allows to change the current logged in user information. The result is a dictionary with OK packet information. Returns a dict() z.Change user is not supported with compression.)rrr|r}r~rurvrrr)rZ _compressrrr$Zmake_change_userr&r*r5r6r%rrrrrr+_post_connection)r:r|r}r~rurqZ ok_packetr?r?r@cmd_change_users2    zMySQLConnection.cmd_change_usercCs|ddS)zGet the current databasezSELECT DATABASE()r) info_queryrr?r?r@r~szMySQLConnection.databasecCs|d|dS)zSet the current databasezUSE %sN)r)r:valuer?r?r@r~ scCs z |WnYdSXdS)a2Reports whether the connection to MySQL Server is available This method checks whether the connection to MySQL is available. It is similar to ping(), but unlike the ping()-method, either True or False is returned and no exception is raised. Returns True or False. FT)rrr?r?r@ is_connecteds  zMySQLConnection.is_connectedc Cs|stdz |Wn.tjk rL||j|j|j|j YnX| }|r| D]\}}| d ||fqb|r| D]\}}| d ||fqdS)aClears 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. rzSET @`{0}` = %szSET SESSION `{0}` = %sN)rrrcmd_reset_connectionrrr,r-r.r+cursoritemsexecuterU)r:Zuser_variablesZsession_variablescurr{rr?r?r@ reset_session s     zMySQLConnection.reset_sessionrc Csd}||kr|d}z |||r2WqWnDtk rx}z&||krhd|t|}t|W5d}~XYnX|dkrt |qdS)aAttempt to reconnect to the MySQL server The argument attempts should be the number of times a reconnect is tried. The delay argument is the number of seconds to wait between each retry. You may want to set the number of attempts higher and use delay when you expect the MySQL server to be down for maintenance or when you expect the network to be temporary unavailable. Raises InterfaceError on errors. rrz4Can not reconnect to MySQL after {0} attempt(s): {1}N) disconnectr8rrlrUrJrrptimesleep)r:attemptsdelaycounterrsrfr?r?r@ reconnectAs" zMySQLConnection.reconnectcCs<z |Wn*|r(|j||dn tdYnXdS)aCheck 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. )rrz%Connection to MySQL is not available.N)rrrrp)r:rrrr?r?r@ping^s  zMySQLConnection.pingcCs(z |jdWStk r"YdSXdS)zMySQL connection IDZserver_threadidN)r&KeyErrorrr?r?r@ connection_idus zMySQLConnection.connection_idc s"||std|dk r>t|ts6td||S|dk rJ|n|j}|dk r\|n|j}d|dkrvdO|dkrdO|dkrdO|dkrd O|dkrd Ot t t t t ttttd }z||WStk rd td dfddtdDYnXdS)aInstantiates and returns a cursor By default, MySQLCursor 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.CursorBase. Raises ProgrammingError when cursor_class is not a subclass of CursorBase. Raises ValueError when cursor is not available. Returns a cursor-object rNz6Cursor class needs be to subclass of cursor.CursorBaserTrrGrdr) rrrGrNrdrr r)rr dictionary named_tuplepreparedz*Cursor not available with given criteria: z, cs$g|]}d|>@dkr|qS)rrr?)rKrr;Z cursor_typer?r@rMsz*MySQLConnection.cursor..r)rrrr issubclassrZProgrammingErrorr1r3rrrrrrrrrrrrZr)r:rrrZ cursor_classrrtypesr?rr@r}sN   zMySQLConnection.cursorcCs|ddS)zCommit current transactionZCOMMITN)_execute_queryrr?r?r@commitszMySQLConnection.commitcCs|jr||ddS)zRollback current transactionZROLLBACKN)rrrrr?r?r@rollbackszMySQLConnection.rollbackcCs|||dS)a Execute a query This method simply calls cmd_query() after checking for unread result. If there are still unread result, an errors.InterfaceError is raised. Otherwise whatever cmd_query() returns is returned. Returns a dict() N)rr)r:rr?r?r@rs zMySQLConnection._execute_querycCs|jdd}|||S)z%Send a query which only returns 1 rowT)r)rrZfetchone)r:rrr?r?r@rs  zMySQLConnection.info_querycCs<|ddkr|j|S|ddkr.t|tddS)aEHandle a MySQL Binary Protocol OK packet This method handles a MySQL Binary Protocol OK packet. When the packet is found to be an Error packet, an error will be raised. If the packet is neither an OK or an Error packet, errors.InterfaceError will be raised. Returns a dict() rdrrezExpected Binary OK packetN)r$Zparse_binary_prepare_okrrkrprr?r?r@_handle_binary_oks    z!MySQLConnection._handle_binary_okcCs|rt|dkrtdnB|ddkr2||S|ddkrH||S|ddkr^t||j|}|rxt|t stddg|}t d|D]}|j |j |j||<q||j }|||fS)a Handle a MySQL Result This method handles a MySQL result, for example, after sending the query command. OK and EOF packets will be handled and returned. If the packet is an Error packet, an errors.Error-exception will be raised. The tuple returned by this method consist of: - the number of columns in the result, - a list of tuples with information about the columns, - the EOF packet information as a dictionary. Returns tuple() or dict() rdrrrrerN)rrrprrrkr$rrrrrr%rjr)r:rqrrrrr?r?r@_handle_binary_results&           z%MySQLConnection._handle_binary_resultcCs0|j||}d|_|jtj|ddd|_dS)zFetch a MySQL statement Result Set This method will send the FETCH command to MySQL together with the given statement id and the number of rows to fetch. FrTN)r$Zmake_stmt_fetchrrr Z STMT_FETCH)r: statement_idrrqr?r?r@cmd_stmt_fetchszMySQLConnection.cmd_stmt_fetchcCs|tj|}||}g|d<g|d<|ddkrxtd|dD]$}|d|j|j |j qB| |j |ddkrtd|dD]$}|d|j|j |j q| |j |S)zPrepare a MySQL statement This method will send the PREPARE command to MySQL together with the given statement. Returns a dict() r parametersZ num_paramsrZ num_columns) rr Z STMT_PREPARErrappendr$rr%rjrr)r:Z statementrqr_r?r?r@cmd_stmt_prepares*   z MySQLConnection.cmd_stmt_preparer?c Cst|}i}|rxt|D]^\}}t||trd}zd||jk}Wntk rXYnX||||||f||<q|j||t ||||j } |j t j | d} || } | S)z"Execute a prepared MySQL statementTb)rq)list enumeraterrmodercmd_stmt_send_long_datar$Zmake_stmt_executetuplerurr Z STMT_EXECUTEr) r:r datar rZlong_data_usedparam_idrrZexecute_packetrqrr?r?r@cmd_stmt_execute7s2  z MySQLConnection.cmd_stmt_executecCs|jtjt|dddS)zDeallocate a prepared MySQL statement This method deallocates the prepared statement using the statement_id. Note that the MySQL server does not return anything. Fr N)rr Z STMT_CLOSErr:r r?r?r@cmd_stmt_closeOszMySQLConnection.cmd_stmt_closec Cs|d}d}|jj}zH||}|rV||||}|jtj|dd|t|7}||}qWntk rvt dYnX|S)a.Send data for a column This methods send data for a column (for example BLOB) for statement identified by statement_id. The param_id indicate which parameter the data belongs too. The data argument should be a file-like object. Since MySQL does not send anything back, no error is raised. When the MySQL server is not reachable, an OperationalError is raised. cmd_stmt_send_long_data should be called before cmd_stmt_execute. The total bytes send is returned. Returns int. i rF)rqrr) r$Z_prepare_stmt_send_long_datarrr ZSTMT_SEND_LONG_DATArrrr) r:r rr chunk_size total_sentZprepare_packetrrqr?r?r@rYs    z'MySQLConnection.cmd_stmt_send_long_datacCs||tjt|dS)zReset data for prepared statement sent as long data The result is a dictionary with OK packet information. Returns a dict() N)rrr Z STMT_RESETrrr?r?r@cmd_stmt_reset|s zMySQLConnection.cmd_stmt_resetcCs2|jdkrtd||tj|dS)zResets the session state without re-authenticating Works only for MySQL server 5.7.3 or later. The result is a dictionary with OK packet information. Returns a dict() )rrNzFMySQL version 5.7.2 and earlier does not support COM_RESET_CONNECTION.N)rmrrrrr ZRESET_CONNECTIONrrr?r?r@rs  z$MySQLConnection.cmd_reset_connectioncCs$|jr|n|jr tddS)z'Check whether there is an unread resultzUnread result foundN)Zcan_consume_resultsrrrrrr?r?r@rs z$MySQLConnection.handle_unread_result)NNNrr"NN)NN)N)NrNTr)F)FNN)NFNNN)FFF)N)r#r#r#r")NN)rr)Frr)NNNNNN)r)r?r?r)<__name__ __module__ __qualname____doc__r(rcrtrrrrrr9rrrrpropertyrrrrrrrrrrrrrrrrrrrr~setterrrrrrrrrrrrrr rrrrrrr __classcell__r?r?r=r@r!:s 3! - (       +  -      %   !    A %   # r!)/r"iorrQrSr^rZauthenticationrZcatch23rrr constantsrr r r r r r#rr conversionrrrrrrrrrrrrnetworkrrprotocolrutilsrrZ abstractsr r!r?r?r?r@s     0