m &Gc@sKdklZlZlZlZlZlZdkZdkZdk Z de fdYZ dei fdYZ de fdYZde fd YZd efd YZd e fd YZdeiefdYZde fdYZde fdYZdeifdYZdeifdYZdS((s exceptionsssqlsschemasutilstypessloggingNtConnectionProvidercBs tZdZdZdZRS(sIdefines an interface that returns raw Connection objects (or compatible).cCs tdS(s`this method should return a Connection or compatible object from a DBAPI which also contains a close() method. It is not defined what context this connection belongs to. It may be newly connected, returned from a pool, part of some other kind of context such as thread-local, or can be a fixed member of this object.N(tNotImplementedError(tself((t:/home/holguin2/public_html/spyce/sqlalchemy/engine/base.pytget_connectionscCs tdS(srreleases all resources corresponding to this ConnectionProvider, such as any underlying connection pools.N(R(R((Rtdispose s(t__name__t __module__t__doc__RR(((RRs  tDialectcBstZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZedZRS(sDefines the behavior of a specific database/DBAPI. Any aspect of metadata defintion, SQL query generation, execution, result-set handling, or anything else which varies between databases is defined under the general category of the Dialect. The Dialect acts as a factory for other database-specific object implementations including ExecutionContext, Compiled, DefaultGenerator, and TypeEngine. All Dialects implement the following attributes: positional - True if the paramstyle for this Dialect is positional paramstyle - the paramstyle to be used (some DBAPIs support multiple paramstyles) supports_autoclose_results - usually True; if False, indicates that rows returned by fetchone() might not be just plain tuples, and may be "live" proxy objects which still require the cursor to be open in order to be read (such as pyPgSQL which has active filehandles for BLOBs). in that case, an auto-closing ResultProxy cannot automatically close itself after results are consumed. convert_unicode - True if unicode conversion should be applied to all str types encoding - type of encoding to use for unicode, usually defaults to 'utf-8' cCs tdS(sJgiven a dictionary of key-valued connect parameters, returns a tuple consisting of a *args/**kwargs suitable to send directly to the dbapi's connect function. The connect args will have any number of the following keynames: host, hostname, database, dbanme, user,username, password, pw, passwd, filename.N(R(Rtopts((Rtcreate_connect_args)scCsdS(sgiven a sql.ClauseParameters object, returns an array or dictionary suitable to pass directly to this Dialect's DBAPI's execute method.N((Rt parameters((Rtconvert_compiled_params/scCs tdS(sprovides a database-specific TypeEngine object, given the generic object which comes from the types module. Subclasses will usually use the adapt_type() method in the types module to make this job easy.N(R(Rttypeobj((Rttype_descriptor2scCs tdS(sareturns the oid column name for this dialect, or None if the dialect cant/wont support OID/ROWID.N(R(R((Rtoid_column_name7scCs tdS(sProvided to indicate when MySQL is being used, which does not have standard behavior for the "rowcount" function on a statement handle. N(R(R((Rtsupports_sane_rowcount:scKs tdS(sreturns a schema.SchemaVisitor instance that can generate schemas, when it is invoked to traverse a set of schema objects. schemagenerator is called via the create() method on Table, Index, and others. N(R(Rtenginetproxytparams((Rtschemagenerator>scKs tdS(sreturns a schema.SchemaVisitor instance that can drop schemas, when it is invoked to traverse a set of schema objects. schemagenerator is called via the drop() method on Table, Index, and others. N(R(RRRR((Rt schemadropperEscKs tdS(sCreturns a schema.SchemaVisitor instances that can execute defaults.N(R(RRRR((Rt defaultrunnerLscCs tdS(sreturns a sql.ClauseVisitor which will produce a string representation of the given ClauseElement and parameter dictionary. This object is usually a subclass of ansisql.ANSICompiler. compiler is called within the context of the compile() method.N(R(Rt statementR ((RtcompilerOscCs tdS(s^given an Connection and a Table object, reflects its columns and properties from the database.N(R(Rt connectionttable((Rt reflecttableVscCs tdS(N(R(RRt table_name((Rt has_tableYscCs tdS(N(R(RRt sequence_name((Rt has_sequence[scCs tdS(sbsubclasses override this method to provide the DBAPI module used to establish connections.N(R(R((Rtdbapi]scCs tdS(s9returns the currently selected schema given an connectionN(R(RR((Rtget_default_schema_nameascCs tdS(s&returns a new ExecutionContext object.N(R(R((Rtexecution_contextdscCs tdS(s0provides an implementation of connection.begin()N(R(RR((Rtdo_begingscCs tdS(s3provides an implementation of connection.rollback()N(R(RR((Rt do_rollbackjscCs tdS(s1provides an implementation of connection.commit()N(R(RR((Rt do_commitmscCs tdS(N(R(RtcursorRR ((Rtdo_executemanypscCs tdS(N(R(RR'RR ((Rt do_executerscCs|id|d|S(scompile the given ClauseElement using this Dialect. a convenience method which simply flips around the compile() call on ClauseElement.tdialectR N(t clauseelementtcompileRR (RR+R ((RR,ts(RRRR R RRRRRRRRRR R!R"R#R$R%R&R(R)tNoneR,(((RR s,                     tExecutionContextcBsVtZdZdZdZdZdZdZdZdZ dZ RS( sa messenger object for a Dialect that corresponds to a single execution. The Dialect should provide an ExecutionContext via the create_execution_context() method. The pre_exec and post_exec methods will be called for compiled statements, afterwhich it is expected that the various methods last_inserted_ids, last_inserted_params, etc. will contain appropriate values, if applicable.cCs tdS(scalled before an execution of a compiled statement. proxy is a callable that takes a string statement and a bind parameter list/dictionary.N(R(RRRtcompiledR ((Rtpre_execscCs tdS(scalled after the execution of a compiled statement. proxy is a callable that takes a string statement and a bind parameter list/dictionary.N(R(RRRR/R ((Rt post_execscCs tdS(sHreturns the count of rows updated/deleted for an UPDATE/DELETE statementN(R(RR'((Rt get_rowcountscCs tdS(sIndicates if the "rowcount" DBAPI cursor function works properly. Currently, MySQLDB does not properly implement this function.N(R(R((RRscCs tdS(sreturn the list of the primary key values for the last insert statement executed. This does not apply to straight textual clauses; only to sql.Insert objects compiled against a schema.Table object, which are executed via statement.execute(). The order of items in the list is the same as that of the Table's 'primary_key' attribute. In some cases, this method may invoke a query back to the database to retrieve the data, based on the "lastrowid" value in the cursor.N(R(R((Rtlast_inserted_idsscCs tdS(sreturn a dictionary of the full parameter dictionary for the last compiled INSERT statement. Includes any ColumnDefaults or Sequences that were pre-executed.N(R(R((Rtlast_inserted_paramsscCs tdS(sreturn a dictionary of the full parameter dictionary for the last compiled UPDATE statement. Includes any ColumnDefaults that were pre-executed.N(R(R((Rtlast_updated_paramsscCs tdS(sreturn True if the last row INSERTED via a compiled insert statement contained PassiveDefaults. The presence of PassiveDefaults indicates that the database inserted data beyond that which we passed to the query programmatically.N(R(R((Rtlastrow_has_defaultss( RRRR0R1R2RR3R4R5R6(((RR.{s       t ConnectablecBsMtZdZdZdZdZdZdZeeddZ RS(skinterface for an object that can provide an Engine and a Connection object which correponds to that Engine.cCs tdS(sDreturns a Connection object which may be part of an ongoing context.N(R(R((Rtcontextual_connectscKs tdS(s<creates a table or index given an appropriate schema object.N(R(Rtentitytkwargs((RtcreatescKs tdS(N(R(RR9R:((RtdropscOs tdS(N(R(Rtobjectt multiparamsR((RtexecutescCs tdS(N(R(R((Rt _not_implstdocs=returns the Engine which this Connectable is associated with.( RRRR8R;R<R?R@tpropertyR(((RR7s      t ConnectioncBstZdZeedZdZedddZeeddZ edddZ d Z d Z d Z d Zd ZdZdZdZdZdZdZedZdZdZedZdZdZdZheie<eie<e i!e<e"i#desRAs?The Engine with which this Connection is associated (read only)s;The underlying DBAPI connection managed by this Connection.cCs|iS(N(RORI(RO((RRPssIndicates if this Connection should be closed when a corresponding ResultProxy is closed; this is essentially an auto-release mode.cCs t||S(N(t TransactionRtparent(RRR((Rt_create_transactionscCs|S(sqconnect() is implemented to return self so that an incoming Engine or Connection object can be treated similarly.N(R(R((RtconnectscKs|S(s|contextual_connect() is implemented to return self so that an incoming Engine or Connection object can be treated similarly.N(R(RR:((RR8scCsA|idjo|id|_|iSn|i|iSdS(N(RRGR-RS(R((Rtbegins cCs |idj S(N(RRGR-(R((Rtin_transactionscCs-|iiid|iii|idS(NtBEGIN(RRDtloggertinfoR*R$R(R((Rt _begin_implscCsC|iiid|iii|i|iid|_ dS(NtROLLBACK( RRDRXRYR*R%RRFtclose_open_cursorsR-RG(R((Rt_rollback_impls cCs6|iiid|iii|id|_dS(NtCOMMIT( RRDRXRYR*R&RR-RG(R((Rt _commit_implscCs?|i o-tid|iio|indS(sawhen no Transaction is present, this is called after executions to provide "autocommit" behavior.s&UPDATE|INSERT|CREATE|DELETE|DROP|ALTERN(RRVtretmatchRtlstriptupperR_(RR((Rt _autocommits-cCs|ip|indS(N(RRVR](R((Rt _autorollbacks cCsGy |i}Wntj o dSnX|iid|_|`dS(N(RRFtcRKtcloseR-(RRf((RRgs    cKs|i|||iS(N(RR?R=R R:tscalar(RR=R R:((RRhscOs'tit|id||||S(Ni(RCt executorsttypeR=t__mro__RR>R(RR=R>R((RR?scKs(|i|iii|i|i|S(N(tdefaulttaccept_schema_visitorRRDR*RRR:(RRlR:((Rtexecute_defaultscCs%|i||}t|i||S(N(Rt _execute_rawRR R't ResultProxyRD(RRR R'((Rt execute_textscOst|djo |gSnwt|djo_|ddjo hgSqt|dtpt|dto |dSq|dgSn|SdS(Nii(tlenR>RR-t isinstancetlistttuple(RR>R((Rt_params_to_listofdictss  ( cOsUt|dj}|o|d}n|}|i|id|i d|||S(NiRR ( RrR>t executemanytparamRRtexecute_compiledtelemR,RD(RRzR>RRwRx((Rtexecute_clauseelements c siig}i||D]}||i |q&~}t |djo|d}nddd}iiiii||||t||ii|||tid|iS(sexecutes a sql.Compiled object.iicsJ|djoSniii|}i||ddS(NR'tcontext( RR-R'RRDR*R R RoR|(RR (RR'R|(RRs  ttypemapN(RRR't_[1]RvR>RtmR/t get_paramsR RrR-RRDR*tcreate_execution_contextR|R0tstrR1RpR}( RR/R>RR~R RR'RR|((RR'R|RRys6icKs|ii|d||S(s<creates a table or index given an appropriate schema object.RN(RRDR;R9R:(RR9R:((RR;3scKs|ii|d||S(s:drops a table or index given an appropriate schema object.RN(RRDR<R9R:(RR9R:((RR<6scKs|ii|d||S(s:reflects the columns in the given table from the database.RN(RRDRRR:(RRR:((RR9scCs|iii|S(N(RRDR*R"(R((Rtdefault_schema_name<scCs ||S(N(t callable_R(RR((Rt run_callable>scKs|djo|ii}ny|iii||iiit||dj oht |t oXt |djoEt |dt pt |dt o|i|||d|n|i|||d||i|Wn nX|S(NiR|(R'R-RRRDRXRYRtreprR RsRtRrtdictt _executemanyR|t_executeRd(RRR R'R|R:((RRo@s XcCs|djo$|iiio f}q1h}ny#|iii|||d|WnLt j o@}|i |i o|inti|||nXdS(NR|(R R-RRDR*t positionalR)RfRR|t ExceptionteReRIRgRLtSQLError(RRfRR R|R((RROs   #  cCsvy#|iii|||d|WnLtj o@}|i |i o|i nt i|||nXdS(NR|(RRDR*R(RfRR R|RRReRIRgRLR(RRfRR R|R((RR]s#  cCs%|iii|}|i||S(sexecutes the given statement string and parameter object. the parameter object is expected to be the result of a call to compiled.get_params(). This callable is a generic version of a connection/cursor-specific callable that is produced within the execute_compiled method, and is used for objects that require this style of proxy when outside of an execute_compiled method, primarily the DefaultRunner.N(RRDR*R R RoR(RRR ((RRfs(.RRRR-tFalseRJRNRBRRtshould_close_with_resultRSRTR8RURVRZR]R_RdReRgRhR?RnRqRvR{Rytsqlt ClauseElementt ClauseVisitortschemat SchemaItemRRkRiR;R<RRRRoRRR(((RRCsD                   :       RQcBsMtZdZdZedddZedZdZdZRS(s\represents a Transaction in progress. the Transaction object is **not** threadsafe.cCsG||_|p||_t|_|i|jo|iindS(N(RRt_Transaction__connectionRRt_Transaction__parenttTruet_Transaction__is_activeRZ(RRRR((RRJss   cCs|iS(N(ROR(RO((RRPysRAs4The Connection object referenced by this TransactioncCs|iS(N(ROR(RO((RRPzscCsP|iipdSn|i|jo|iit|_n|iidS(N(RRRRR]Rtrollback(R((RR{s    cCsN|iiptidn|i|jo|iit|_ndS(NsThis transaction is inactive(RRRRLRMRR_R(R((Rtcommits   ( RRRRJRBRt is_activeRR(((RRQos   tEnginecBstZdZedZedZedZei Z dZ edZ edZ dZdZeeZd Zed Zed Zed Zd ZdZdZdZdZedZedZdZdZdZRS(s Connects a ConnectionProvider, a Dialect and a CompilerFactory together to provide a default implementation of SchemaEngine. cCs1||_||_||_ti||_dS(N(tconnection_providerRR*techotloggingtinstance_loggerRX(RRR*R((RRJs   cCsti|iiidS(Ntname(tsystmodulesROR*Rt descriptor(RO((RRPscCs|S(N(RO(RO((RRPscCs|iidS(N(RRR(R((RRscKs#|i|ii|d||dS(s^creates a table or index within this engine's database connection given a schema.Table object.RN(Rt _run_visitorR*RR9RR:(RR9RR:((RR;scKs#|i|ii|d||dS(s\drops a table or index within this engine's database connection given a schema.Table object.RN(RRR*RR9RR:(RR9RR:((RR<scKs2|i}z|i||SWd|iXdS(N(RR8RRnRlR:Rg(RRlR:R((RRns  cCs ti|S(N(Rt_FunctionGeneratorR(R((Rt_funcscOsti|d|||S(s;returns a sql.text() object for performing literal queries.RN(RttextRtargsR:(RRRR:((RRscKsr|djo|i}n|}z,|i|||id||dt Wd|djo|i nXdS(NRttraverse( RR-RR8tconntelementRmtvisitorcallableRR:RRg(RRRRR:R((RRs , cOs|djo|i}n|}zK|i}y$||||}|i |SWn|i nXWd|djo|i nXdS(s9executes the given function within a transaction boundary. this is a shortcut for explicitly calling begin() and commit() and optionally rollback() when execptions are raised. The given *args and **kwargs will be passed to the function, as well as the Connection used in the transaction.N(RR-RR8RRUttransRRR:tretRRRg(RRRRR:RRR((Rt transactions       cOsZ|djo|i}n|}z||||SWd|djo|inXdS(N( RR-RR8RRRR:Rg(RRRRR:R((RRs  cOs%|idt}|i|||S(NRH(RR8RRR?RR>R(RRR>RR((RR?scOs|i|||iS(N(RR?RR>RRh(RRR>R((RRhscOs%|idt}|i|||S(NRH(RR8RRRyR/R>R(RR/R>RR((RRyscKs|ii||d||S(NR(RR*RRR R:(RRR R:((RRscKs t||S(s,returns a newly allocated Connection object.N(RCRR:(RR:((RRTscKst|d||S(sreturns a Connection object which may be newly allocated, or may be part of some ongoing context. This Connection is meant to be used by the various "auto-connecting" operations.RHN(RCRRHR:(RRHR:((RR8scCs]|djo|i}n|}z|ii||Wd|djo|inXdS(sLgiven a Table object, reflects its columns and properties from the database.N( RR-RR8RR*RRRg(RRRR((RRs  csidS(Ncsii|S(N(RR*RRfR(Rf(RR(RRPs(RR(RR((RRRRscCs |iiS(sreturns a DBAPI connection.N(RRR(R((RREscCs|ii|dS(s4logs a message using this SQLEngine's logger stream.N(RRXRYtmsg(RR((Rtlogs( RRRR-RJRBRRRt echo_propertyRRR;R<RnRtfuncRRRRR?RhRyRRTRR8RRRER(((RRs2                   RpcBstZdZdefdYZeedZdZeeZ dZ dZ dZ dZ d Zd Zd Zd Zd ZdZdZdZdZRS(swraps a DBAPI cursor object to provide access to row columns based on integer position, case-insensitive column name, or by schema.Column object. e.g.: row = fetchone() col1 = row[0] # access via integer position col2 = row['col2'] # access via name col3 = row[mytable.c.mycol] # access via Column object. ResultProxy also contains a map of TypeEngine objects and will invoke the appropriate convert_result_value() method before returning columns, as well as the ExecutionContext corresponding to the statement execution. It provides several methods for which to obtain information from the underlying ExecutionContext. tAmbiguousColumncBs#tZdZdZdZRS(NcCs ||_dS(N(tkeyR(RR((RRJscCs|S(N(R(RR*((Rt dialect_implscCstid|idS(NsVAmbiguous column name '%s' in result set! try 'use_labels' option on select statement.(RLRMRR(RtargR((Rtconvert_result_values(RRRJRR(((RRs  c Cs||_|i|_||_||_t|_|dj o||_ |i ||_ n |i |_ h|_ |i dj|_|i} h|_g|_d}| dj ox| D]}|diddi}|dj o|i|ti|f} nti|f} | ddjotd|n|ii|| | j o ti |df|i|