ó ň6ĹRc@sËdZddlZddlZy ddlmZmZmZWn#ek rceZe Ze ZnXdZ ej e ej ejBejBƒZddlmZmZmZmZmZmZmZmZmZmZdefd„ƒYZdefd „ƒYZd efd „ƒYZd efd „ƒYZ defd„ƒYZ!de!fd„ƒYZ"dee efd„ƒYZ#dee!efd„ƒYZ$dee efd„ƒYZ%dee!efd„ƒYZ&dS(szMySQLdb Cursors This module implements Cursors of various types for MySQLdb. By default, MySQLdb uses the Cursor class. i˙˙˙˙N(tListTypet TupleTypet UnicodeTypesß \s values \s* ( \( [^()']* (?: (?: (?:\( # ( - editor hightlighting helper .* \)) | ' [^\\']* (?:\\.[^\\']*)* ' ) [^()']* )* \) ) ( tWarningtErrortInterfaceErrort DataErrort DatabaseErrortOperationalErrortIntegrityErrort InternalErrortNotSupportedErrortProgrammingErrort BaseCursorcBsGeZdZddlmZmZmZmZmZm Z m Z m Z m Z m Z mZeZd„Zd„Zd„Zd„Zd„Zd„Zd „Zd „Zd „Zd „Zd „Zdd„Zd„Zdd„Zd„Z d„Z!dd„Z"d„Z#eZeZeZeZe Z e Z e Z e Z e Z eZRS(sA 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 i˙˙˙˙( t MySQLErrorRRRRRRR R R R cCs’ddlm}||ƒ|_d|_d|_d|_d|_d|_d|_ g|_ |j |_ d|_ d|_ d|_d|_dS(Ni˙˙˙˙(tproxyii(tweakrefRt connectiontNonet descriptiontdescription_flagstrowcountt arraysizet _executedt lastrowidtmessagest errorhandlert_resultt _warningst_infot rownumber(tselfRR((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyt__init__Ks           cCs |jƒd|_d|_dS(N(tcloseRRR(R((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyt__del__\s  cCs-|js dSx|jƒrqWd|_dS(s6Close the cursor. No further queries will be possible.N(RtnextsetR(R((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR!as  cCs#|js|j|tdƒndS(Nsexecute() first(RRR (R((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyt_check_executedgs cCsËddlm}|jrÇ|jƒjƒ}|r†x'|D]}|jj|j|fƒq8Wxf|D]}||d|jdƒqbWqÇ|jrÇ|jj|j|jfƒ||j|jdƒqÇndS(Ni˙˙˙˙(twarni( twarningsR%Rt_get_dbt show_warningsRtappendRR(RR%R&tw((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyt_warning_checkks    cCsg|jr|jƒn|j2|jƒ}|jƒ}|dkrEdS|jƒ|jƒ|jƒdS(s`Advance to the next result set. Returns None if there are no more result sets. i˙˙˙˙iN( RtfetchallRR't next_resultRt_do_get_resultt_post_get_resultR+(Rtdbtnr((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR#zs        cCsdS(N((R((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR/ŒscCsŚ|jƒ}|jƒ|_|jƒ|_d|_|jrK|jjƒpNd|_|jrl|jj ƒpod|_ |j ƒ|_ |j ƒ|_|jƒ|_dS(Ni(R't _get_resultRt affected_rowsRRtdescribeRRt field_flagsRt insert_idRt warning_countRtinfoR(RR0((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR.Žs  !!cGsdS(s!Does nothing, required by DB API.N((Rtargs((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyt setinputsizes™scGsdS(s!Does nothing, required by DB API.N((RR9((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pytsetoutputsizesœscCs&|js|j|tdƒn|jS(Ns cursor closed(RRR (R((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR'Ÿs c sŐ|j2|jƒ‰t|tƒr:|jˆjjƒ}n|dk r­t|tƒr~|t‡fd†|j ƒDƒƒ}q­|t g|D]}ˆj |ƒ^q‹ƒ}nyd}|j |ƒ}Wnét k rQ}|jddkr%|jjt|jdfƒ|j|t|jdƒq˛|jjt |fƒ|j|t |ƒnattfk rj‚nHtjƒ\}}}~|jj||fƒ|j|||ƒnX||_|jsŃ|jƒn|S(sŒExecute 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 long integer rows affected, if any c3s*|] \}}|ˆj|ƒfVqdS(N(tliteral(t.0tkeytitem(R0(sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pys ¸sis&not enough arguments for format stringsnot all arguments convertedN(s&not enough arguments for format stringsnot all arguments converted(RR't isinstancetunicodetencodetunicode_literaltcharsetRtdictt iteritemsttupleR<t_queryt TypeErrorR9R)R Rt SystemExittKeyboardInterrupttsystexc_infoRt_defer_warningsR+( RtqueryR9R?trtmtexctvaluettb((R0sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pytexecute¤s<  /    cs3|j2|jƒ‰|sdSt|tƒrD|jˆjjƒ}ntj|ƒ}|sŠd}x$|D]}||j ||ƒ}qfW|S|j dƒ}|j dƒ}|j dƒ}yg} x€|D]x}t|t ƒr | j|t ‡fd†|jƒDƒƒƒqÇ| j|tg|D]} ˆj| ƒ^qƒƒqÇWWn tk rœ} | jdd kr†|j|t| jdƒqç|j|t| ƒnKttfk rľ‚n2tjƒ\} } }~|j|| | ƒnX|jdj|| dj| ƒ||gƒƒ}|js/|jƒn|S( s°Execute a multi-row query. query -- string, query to execute on server args Sequence of sequences or mappings, parameters to use with query. Returns long integer rows affected, if any. This method improves performance on multiple-row INSERT and REPLACE. Otherwise it is equivalent to looping over args with execute(). Niic3s*|] \}}|ˆj|ƒfVqdS(N(R<(R=R>R?(R0(sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pys öss&not enough arguments for format stringsnot all arguments converteds s, (s&not enough arguments for format stringsnot all arguments converted(RR'R@RARBRCRDt insert_valuestsearchRUtstarttendtgroupRER)RFRGR<RIR9RR RJRKRLRMRHtjoinRNR+(RROR9RQRPtatptetqvtqR?tmsgRRRSRT((R0sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyt executemanyŇsJ   ;  2 cCs|jƒ}xtt|ƒD]f\}}d|||j|ƒf}t|tƒrh|j|jjƒ}n|j|ƒ|j ƒqWd|dj gt t |ƒƒD]}d||f^q˘ƒf}t |ƒtkrď|j|jjƒ}n|j|ƒ||_|js|jƒn|S(s'Execute 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. sSET @_%s_%d=%ss CALL %s(%s)t,s@_%s_%d(R't enumerateR<R@RARBRCRDRHR#R[trangetlenttypeRRRNR+(RtprocnameR9R0tindextargR`ti((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pytcallproc s$    3   cCs3|jƒ}||_|j|ƒ|jƒ|jS(N(R't_last_executedROR.R(RR`R0((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyt _do_query;s     cCs |j|ƒS(N(Rn(RR`((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyRHBsicCs#|js dS|jj||jƒS(N((Rt fetch_rowt _fetch_type(Rtsize((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyt _fetch_rowDs cCst|jdƒS(N(titertfetchoneR(R((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyt__iter__IsN(($t__name__t __module__t__doc__t_mysql_exceptionsRRRRRRRR R R R tFalseRNR R"R!R$R+R#R/R.R:R;R'RRURbRlRnRHRrRu(((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR 2s>L           . 8 1    tCursorStoreResultMixIncBs\eZdZd„Zd„Zd„Zd„Zd d„Zd„Z dd„Z d „Z RS( sThis 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|jƒjƒS(N(R't store_result(R((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR2_scCs|j|ƒ}|jƒ|S(N(RnR/(RR`R((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyRHas cCs|jdƒ|_d|_dS(Ni(Rrt_rowsRR(R((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR/fscCsJ|jƒ|jt|jƒkr&dS|j|j}|jd|_|S(s]Fetches a single row from the cursor. None indicates that no more rows are available.iN(R$RRfR}R(Rtresult((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyRtjs  cCsR|jƒ|j|p|j}|j|j|!}t|t|jƒƒ|_|S(s…Fetch up to size rows from the cursor. Result set may be smaller than size. If size is not defined, cursor.arraysize is used.(R$RRR}tminRf(RRqRYR~((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyt fetchmanyss  cCsE|jƒ|jr&|j|j}n |j}t|jƒ|_|S(s*Fetchs all available rows from the cursor.(R$RR}Rf(RR~((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR,|s    trelativecCsœ|jƒ|dkr&|j|}n2|dkr;|}n|j|tdt|ƒƒ|dksy|t|jƒkr|j|tdƒn||_dS(sScroll 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.Rtabsolutesunknown scroll mode %sis out of rangeN(R$RRR treprRfR}t IndexError(RRStmodeRP((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pytscroll†s     !cCs6|jƒ|jr#|j|jp)|j}t|ƒS(N(R$RR}Rs(RR~((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyRu™s "N( RvRwRxR2RHR/RtRR€R,R†Ru(((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR{Xs    tCursorUseResultMixIncBsMeZdZeZd„Zd„Zdd„Zd„Z d„Z d„Z RS(sThis 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 peformed on the connection.cCs|jƒjƒS(N(R't use_result(R((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR2ŠscCsE|jƒ|jdƒ}|s-|jƒdS|jd|_|dS(s%Fetches a single row from the cursor.iiN(R$RrR+RR(RRP((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyRtŤs  cCsO|jƒ|j|p|jƒ}|jt|ƒ|_|sK|jƒn|S(s…Fetch up to size rows from the cursor. Result set may be smaller than size. If size is not defined, cursor.arraysize is used.(R$RrRRRfR+(RRqRP((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR€ľs   cCs=|jƒ|jdƒ}|jt|ƒ|_|jƒ|S(s*Fetchs all available rows from the cursor.i(R$RrRRfR+(RRP((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR,żs   cCs|S(N((R((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyRuÇscCs%|jƒ}|dkr!t‚n|S(N(RtRt StopIteration(Rtrow((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pytnextĘs   N( RvRwRxtTrueRNR2RtRR€R,RuR‹(((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR‡Ÿs   tCursorTupleRowsMixIncBseZdZdZRS(swThis is a MixIn class that causes all rows to be returned as tuples, which is the standard form required by DB API.i(RvRwRxRp(((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyRŃstCursorDictRowsMixIncBs2eZdZdZd„Zdd„Zd„ZRS(snThis is a MixIn class that causes all rows to be returned as dictionaries. This is a non-standard feature.icCs*ddlm}|dtdƒ|jƒS(sgFetch a single row as a dictionary. Deprecated: Use fetchone() instead. Will be removed in 1.3.i˙˙˙˙(R%s9fetchoneDict() is non-standard and will be removed in 1.3i(R&R%tDeprecationWarningRt(RR%((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyt fetchoneDictŕs cCs-ddlm}|dtdƒ|j|ƒS(srFetch several rows as a list of dictionaries. Deprecated: Use fetchmany() instead. Will be removed in 1.3.i˙˙˙˙(R%s:fetchmanyDict() is non-standard and will be removed in 1.3i(R&R%RR€(RRqR%((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyt fetchmanyDictčs cCs*ddlm}|dtdƒ|jƒS(swFetch all available rows as a list of dictionaries. Deprecated: Use fetchall() instead. Will be removed in 1.3.i˙˙˙˙(R%s9fetchallDict() is non-standard and will be removed in 1.3i(R&R%RR,(RR%((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyt fetchallDictđs N(RvRwRxRpRRR‘R’(((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyRŽŮs   tCursorOldDictRowsMixIncBseZdZdZRS(sŽThis is a MixIn class that returns rows as dictionaries with the same key convention as the old Mysqldb (MySQLmodule). Don't use this.i(RvRwRxRp(((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR“ůstCursorcBseZdZRS(sjThis is the standard Cursor class that returns rows as tuples and stores the result set in the client.(RvRwRx(((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR”st DictCursorcBseZdZRS(seThis is a Cursor class that returns rows as dictionaries and stores the result set in the client.(RvRwRx(((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR• stSSCursorcBseZdZRS(s_This is a Cursor class that returns rows as tuples and stores the result set in the server.(RvRwRx(((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR–st SSDictCursorcBseZdZRS(seThis is a Cursor class that returns rows as dictionaries and stores the result set in the server.(RvRwRx(((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyR—s('RxtreRLttypesRRRt ImportErrortlistRGtstrtrestrtcompiletStItXRVRyRRRRRRR R R R tobjectR R{R‡RRŽR“R”R•R–R—(((sB/opt/alt/python27/lib64/python2.7/site-packages/MySQLdb/cursors.pyts4     #F˙'G2