JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrJFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrB WO@sPdZddlmZmZddlmZddlZddlZddlm Z ddl m Z m Z m Z mZmZmZmZmZmZmZejddkZere ZneZedejejBZGd d d eZGd d d eZGd ddeZ GdddeZ!GdddeZ"Gddde"Z#Gdddee!eZ$Gdddee"eZ%Gddde e!eZ&Gddde e"eZ'dS)zyMySQLdb Cursors This module implements Cursors of various types for MySQLdb. By default, MySQLdb uses the Cursor class. )print_functionabsolute_import)partialN)unicode) WarningErrorInterfaceError DataError DatabaseErrorOperationalErrorIntegrityError InternalErrorNotSupportedErrorProgrammingErrorzw\s*((?:INSERT|REPLACE)\s.+\sVALUES?\s+)(\(\s*(?:%s|%\(.+\)s)\s*(?:,\s*(?:%s|%\(.+\)s)\s*)*\))(\s*(?:ON DUPLICATE.*)?)\Zc@s0eZdZdZdZddlmZmZmZm Z m Z m Z m Z m Z mZmZmZdZdZddZd d Zd d Zd dZd5ddZddZddZddZddZddZddZddZdd Zd!d"Z d6d#d$Z!d%d&Z"d'd(Z#d7d*d+Z$d,d-Z%d.d/Z&d8d1d2Z'd3d4Z(eZeZe Z e Z e Z e Z e Z eZeZeZdS)9 BaseCursoraA base for Cursor classes. Useful attributes: description A tuple of DB API 7-tuples describing the columns in the last executed query; see PEP-249 for details. description_flags Tuple of column flags for last query, one entry per column in the result set. Values correspond to those in MySQLdb.constants.FLAG. See MySQL documentation (C API) for more information. Non-standard extension. arraysize default number of rows fetchmany() will fetch ir) MySQLErrorrrrr r r r r rrFNcCsN||_d|_d|_d|_d|_d|_d|_g|_|j|_d|_ d|_ d|_ dS)N) connection descriptiondescription_flagsrowcount arraysize _executed lastrowidmessages errorhandler_result _warnings rownumber)selfrr"B/opt/alt/python37/lib64/python3.7/site-packages/MySQLdb/cursors.py__init__AszBaseCursor.__init__cCs:z |jdkrdSx |rqWWdd|_d|_d|_XdS)z6Close the cursor. No further queries will be possible.N)rnextsetrr)r!r"r"r#closeOs  zBaseCursor.closecCs|S)Nr")r!r"r"r# __enter__[szBaseCursor.__enter__cGs~|dS)N)r&)r!exc_infor"r"r#__exit__^szBaseCursor.__exit__csDt|tr|}n*t|ttfr@t|fdd|D}|S)Nc3s|]}j|dVqdS))encodingN) _ensure_bytes).0v)r*r!r"r# fsz+BaseCursor._ensure_bytes..) isinstance text_typeencodetuplelisttype)r!xr*r")r*r!r#r+bs   zBaseCursor._ensure_bytescst|jjdt|ttfrFtr0tt|}tfdd|DSt|trtrntfdd| D}tfdd| DStr|} |SdS)N)r*c3s|]}|VqdS)N)literal)r,arg)connr"r#r.osz*BaseCursor._escape_args..c3s"|]\}}||fVqdS)Nr")r,keyval) ensure_bytesr"r#r.rsc3s |]\}}||fVqdS)N)r6)r,r9r:)r8r"r#r.ts) rr+r*r/r2r3PY2mapdictitemsr6)r!argsr8r")r8r;r# _escape_argsis  zBaseCursor._escape_argscCs|js||tddS)Nzexecute() first)rrr)r!r"r"r#_check_executed|szBaseCursor._check_executedcCsddlm}|}|jdkr(||_|jr|j}d|_|jrv|jjrvd|f}|j||| d|dddS| }|rx|D]}|j|j |fqWxZ|D]}||j |ddddqWn2| }|r|j|j |f|| d|dddS)Nr)warnzThere are %d MySQL warnings.) stacklevelr) warningsrC_get_dbr warning_countrZhas_nextrappendrZ show_warningsinfo)r!rCdbrHmsgrFwrJr"r"r#_warning_checks,        zBaseCursor._warning_checkcCsR|jr||jdd=|}|}|dkr6dS|||dS)z`Advance to the next result set. Returns None if there are no more result sets. Nrr)rfetchallrrGZ next_result_do_get_result_post_get_resultrN)r!rKnrr"r"r#r%s zBaseCursor.nextsetcCsdS)Nr")r!r"r"r#rQzBaseCursor._post_get_resultcCsb|}||_||_d|_|jr2|jp4d|_|jrH|jpJd|_ | |_ d|_ dS)Nr) rG _get_resultrZ affected_rowsrr ZdescriberZ field_flagsrZ insert_idrr)r!rKr"r"r#rPs   zBaseCursor._do_get_resultcGsdS)z!Does nothing, required by DB API.Nr")r!r@r"r"r# setinputsizesszBaseCursor.setinputsizescGsdS)z!Does nothing, required by DB API.Nr")r!r@r"r"r#setoutputsizesszBaseCursor.setoutputsizescCs|j}|dkrtd|S)Nz cursor closed)rr)r!Zconr"r"r#rGszBaseCursor._get_dbc sRx |r qW|tr2t|tr2|jj}|dk rt|tr`tfdd| D}nt t j |}tst|t tfr|jj}y ||}Wn4tk r}z||tt|Wdd}~XYnXt|tr|jjd}d}y||}Wn8tk r6tdd\}}||||YnX||_|jsN||S)aExecute a query. query -- string, query to execute on server args -- optional sequence or mapping, parameters to use with query. Note: If args is a sequence, then %s must be used as the parameter placeholder in the query. If a mapping is used, %(key)s must be used as the placeholder. Returns integer represents rows affected, if any Nc3s |]\}}||fVqdS)N)r6)r,r9item)rKr"r#r.sz%BaseCursor.execute..surrogateescaper)r%rGr<r/rr1unicode_literalcharsetr>r?r2r=r6bytes bytearraydecode TypeErrorrrstr_query Exceptionsysr(r_defer_warningsrN)r!queryr@mresexcvaluer")rKr#executes6    $ zBaseCursor.executec sjdd=|sdSt}|r|dd}|d}|dpJd}|ddkrd|d d ksht||||jj St fd d |D_ j S) axExecute a multi-row query. :param query: query to execute on server :param args: Sequence of sequences or mappings. It is used as parameter. :return: Number of rows affected, if any. This method improves performance on multiple-row INSERT and REPLACE. Otherwise it is equivalent to looping over args with execute(). Nrr"rrDr(r)c3s|]}|VqdS)N)ri)r,r7)rdr!r"r#r.sz)BaseCursor.executemany..) rRE_INSERT_VALUESmatchgrouprstripAssertionError_do_execute_manymax_stmt_lengthrGr*sumr)r!rdr@reZq_prefixZq_valuesZ q_postfixr")rdr!r# executemanys    zBaseCursor.executemanyc CsN|}|j}t|tr"||}tr:t|tr:||}t|trN||}t|} t|}||t||} t| trtr| |} n | |d} | | 7} d} x|D]} ||| |} t| trtr| |} n | |d} t | t | t |d|kr| | | |7} t|} n| d7} | | 7} qW| | | |7} | |_ | S)NrXrr,) rGrAr/r0r1r<r\iternextlenrir) r!prefixvaluesZpostfixr@rsr*r8escapeZsqlr-Zrowsr7r"r"r#rrs>            "  zBaseCursor._do_execute_manyr"cs|}xTt|D]H\}}d|||f}t|trH||jjd}||| qWdd fddt t |Df}t|tr||jjd}||||_ |js||S)aExecute stored procedure procname with args procname -- string, name of procedure to execute on server args -- Sequence of parameters to use with procedure Returns the original args. Compatibility warning: PEP-249 specifies that any modified parameters must be returned. This is currently impossible as they are only available by storing them in a server variable and then retrieved by a query. Since stored procedures return zero or more result sets, there is no reliable way to get at OUT or INOUT parameters via callproc. The server variables are named @_procname_n, where procname is the parameter above and n is the position of the parameter (from zero). Once all result sets generated by the procedure have been fetched, you can issue a SELECT @_procname_0, ... query using .execute() to get any OUT or INOUT values. Compatibility warning: The act of calling a stored procedure itself creates an empty result set. This appears after any result sets generated by the procedure. This is non-standard behavior with respect to the DB-API. Be sure to use nextset() to advance through all result sets; otherwise you may get disconnected. zSET @_%s_%d=%srXz CALL %s(%s),csg|]}d|fqS)z@_%s_%dr")r,i)procnamer"r# isz'BaseCursor.callproc..)rG enumerater6r/rr1rYrZr`r%joinrangeryrrcrN)r!rr@rKindexr7qr")rr#callprocBs$     zBaseCursor.callproccCs&|}||_||||jS)N)rGZ_last_executedrdrPr)r!rrKr"r"r# _do_queryss  zBaseCursor._do_querycCs ||S)N)r)r!rr"r"r#r`zszBaseCursor._queryrcCs|js dS|j||jS)Nr")rZ fetch_row _fetch_type)r!sizer"r"r# _fetch_row}szBaseCursor._fetch_rowcCs t|jdS)N)rwfetchone)r!r"r"r#__iter__szBaseCursor.__iter__)N)N)r")r))__name__ __module__ __qualname____doc__rs_mysql_exceptionsrrrrr r r r r rrrcrr$r&r'r)r+rArBrNr%rQrPrUrVrGrirurrrrr`rrr"r"r"r#r#sJ4  "  4$ 1 rc@sTeZdZdZddZddZddZdd Zdd d Zd dZ dddZ ddZ d S)CursorStoreResultMixInaThis is a MixIn class which causes the entire result set to be stored on the client side, i.e. it uses mysql_store_result(). If the result set can be very large, consider adding a LIMIT clause to your query, or using CursorUseResultMixIn instead.cCs |S)N)rGZ store_result)r!r"r"r#rTsz"CursorStoreResultMixIn._get_resultcCs||}||S)N)rrQ)r!rrr"r"r#r`s zCursorStoreResultMixIn._querycCs|d|_d|_dS)Nr)r_rowsr)r!r"r"r#rQs z'CursorStoreResultMixIn._post_get_resultcCs8||jt|jkrdS|j|j}|jd|_|S)z]Fetches a single row from the cursor. None indicates that no more rows are available.Nr)rBr ryr)r!resultr"r"r#rs   zCursorStoreResultMixIn.fetchoneNcCs>||j|p|j}|j|j|}t|t|j|_|S)zFetch up to size rows from the cursor. Result set may be smaller than size. If size is not defined, cursor.arraysize is used.)rBr rrminry)r!rendrr"r"r# fetchmanys z CursorStoreResultMixIn.fetchmanycCs6||jr |j|jd}n|j}t|j|_|S)z*Fetchs all available rows from the cursor.N)rBr rry)r!rr"r"r#rOs  zCursorStoreResultMixIn.fetchallrelativecCsn||dkr|j|}n$|dkr*|}n||tdt||dksV|t|jkrd||td||_dS)aScroll the cursor in the result set to a new position according to mode. If mode is 'relative' (default), value is taken as offset to the current position in the result set, if set to 'absolute', value states an absolute target position.rZabsolutezunknown scroll mode %srz out of rangeN)rBr rrreprryr IndexError)r!rhmoderr"r"r#scrolls zCursorStoreResultMixIn.scrollcCs,||jr|j|jdp"|j}t|S)N)rBr rrw)r!rr"r"r#rszCursorStoreResultMixIn.__iter__)N)r) rrrrrTr`rQrrrOrrr"r"r"r#rs  rc@sJeZdZdZdZddZddZddd Zd d Zd d Z ddZ e Z dS)CursorUseResultMixInaThis is a MixIn class which causes the result set to be stored in the server and sent row-by-row to client side, i.e. it uses mysql_use_result(). You MUST retrieve the entire result set and close() the cursor before additional queries can be performed on the connection.TcCs |S)N)rGZ use_result)r!r"r"r#rTrSz CursorUseResultMixIn._get_resultcCs6||d}|s"|dS|jd|_|dS)z%Fetches a single row from the cursor.rNr)rBrrNr )r!rr"r"r#rs  zCursorUseResultMixIn.fetchoneNcCs8|||p|j}|jt||_|s4||S)zFetch up to size rows from the cursor. Result set may be smaller than size. If size is not defined, cursor.arraysize is used.)rBrrr ryrN)r!rrr"r"r#rs zCursorUseResultMixIn.fetchmanycCs.||d}|jt||_||S)z*Fetchs all available rows from the cursor.r)rBrr ryrN)r!rr"r"r#rOs  zCursorUseResultMixIn.fetchallcCs|S)Nr")r!r"r"r#rszCursorUseResultMixIn.__iter__cCs|}|dkrt|S)N)r StopIteration)r!rowr"r"r#rxszCursorUseResultMixIn.next)N) rrrrrcrTrrrOrrx__next__r"r"r"r#rs rc@seZdZdZdZdS)CursorTupleRowsMixInzwThis is a MixIn class that causes all rows to be returned as tuples, which is the standard form required by DB API.rN)rrrrrr"r"r"r#r src@s.eZdZdZdZddZd ddZdd ZdS) CursorDictRowsMixInznThis is a MixIn class that causes all rows to be returned as dictionaries. This is a non-standard feature.rcCs ddlm}|dtd|S)zgFetch a single row as a dictionary. Deprecated: Use fetchone() instead. Will be removed in 1.3.r)rCz9fetchoneDict() is non-standard and will be removed in 1.3r)rFrCDeprecationWarningr)r!rCr"r"r# fetchoneDicts z CursorDictRowsMixIn.fetchoneDictNcCs"ddlm}|dtd||S)zrFetch several rows as a list of dictionaries. Deprecated: Use fetchmany() instead. Will be removed in 1.3.r)rCz:fetchmanyDict() is non-standard and will be removed in 1.3r)rFrCrr)r!rrCr"r"r# fetchmanyDict"s z!CursorDictRowsMixIn.fetchmanyDictcCs ddlm}|dtd|S)zwFetch all available rows as a list of dictionaries. Deprecated: Use fetchall() instead. Will be removed in 1.3.r)rCz9fetchallDict() is non-standard and will be removed in 1.3r)rFrCrrO)r!rCr"r"r# fetchallDict*s z CursorDictRowsMixIn.fetchallDict)N)rrrrrrrrr"r"r"r#rs  rc@seZdZdZdZdS)CursorOldDictRowsMixInzThis is a MixIn class that returns rows as dictionaries with the same key convention as the old Mysqldb (MySQLmodule). Don't use this.rN)rrrrrr"r"r"r#r3src@seZdZdZdS)CursorzjThis is the standard Cursor class that returns rows as tuples and stores the result set in the client.N)rrrrr"r"r"r#r;src@seZdZdZdS) DictCursorzeThis is a Cursor class that returns rows as dictionaries and stores the result set in the client.N)rrrrr"r"r"r#rAsrc@seZdZdZdS)SSCursorz_This is a Cursor class that returns rows as tuples and stores the result set in the server.N)rrrrr"r"r"r#rGsrc@seZdZdZdS) SSDictCursorzeThis is a Cursor class that returns rows as dictionaries and stores the result set in the server.N)rrrrr"r"r"r#rMsr)(r __future__rr functoolsrrerbZMySQLdb.compatrrrrrr r r r r rr version_infor<r0r_compile IGNORECASEDOTALLrmobjectrrrrrrrrrrr"r"r"r#s:  0pH4