ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ 4]c@sdZddlmZddlmZddlmZddlmZddlmZddlmZdd lm Z dd l m Z dd lm Z dd lmZejd ZdefdYZdS(sProvides an abstraction for obtaining database schema information. Usage Notes: Here are some general conventions when accessing the low level inspector methods such as get_table_names, get_columns, etc. 1. Inspector methods return lists of dicts in most cases for the following reasons: * They're both standard types that can be serialized. * Using a dict instead of a tuple allows easy expansion of attributes. * Using a list for the outer structure maintains order and is easy to work with (e.g. list comprehension [d['name'] for d in cols]). 2. Records that contain a name, such as the column name in a column record use the key 'name'. So for most return values, each record will have a 'name' attribute.. i(t Connectablei(texc(t inspection(tsql(tutil(t operators(tschema(t TypeEngine(t deprecated(t topologicalcOs|jdd}|dkr1|||||S|jtd|Dtd|jDf}|j|}|dkr|||||}|||/scssA|]7\}}t|tjtjtfr||fVqdS(N(R RR t int_typestfloat(R tktv((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pys 1s (tgettNonet__name__ttupletitems(tfntselftcontargstkwR tkeytret((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pytcache(s   t InspectorcBseZdZdZedZejedZ e dZ dZ e jdd'd(d(d Zd(d Zd Zd Zd(d Zd(dZd(dZd(dZeddd(dZd(dZd(dZd(dZd(dZd(dZd(dZd)e d(dZ!dZ"dZ#dZ$dZ%de&j'fd e&j(fd!e&j)fd"e&j*fgZ+d#Z,d$Z-d%Z.d&Z/RS(*smPerforms database schema inspection. The Inspector acts as a proxy to the reflection methods of the :class:`~sqlalchemy.engine.interfaces.Dialect`, providing a consistent interface as well as caching support for previously fetched metadata. A :class:`.Inspector` object is usually created via the :func:`.inspect` function:: from sqlalchemy import inspect, create_engine engine = create_engine('...') insp = inspect(engine) The inspection method above is equivalent to using the :meth:`.Inspector.from_engine` method, i.e.:: engine = create_engine('...') insp = Inspector.from_engine(engine) Where above, the :class:`~sqlalchemy.engine.interfaces.Dialect` may opt to return an :class:`.Inspector` subclass that provides additional methods specific to the dialect's target database. cCsn||_t|dr'|j|_n ||_|j|krR|jjn|jj|_i|_dS(sjInitialize a new :class:`.Inspector`. :param bind: a :class:`~sqlalchemy.engine.Connectable`, which is typically an instance of :class:`~sqlalchemy.engine.Engine` or :class:`~sqlalchemy.engine.Connection`. For a dialect-specific instance of :class:`.Inspector`, see :meth:`.Inspector.from_engine` tengineN(tbindthasattrR!tconnecttclosetdialectR (RR"((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyt__init__Xs  cCs,t|jdr"|jj|St|S(sConstruct a new dialect-specific Inspector object from the given engine or connection. :param bind: a :class:`~sqlalchemy.engine.Connectable`, which is typically an instance of :class:`~sqlalchemy.engine.Engine` or :class:`~sqlalchemy.engine.Connection`. This method differs from direct a direct constructor call of :class:`.Inspector` in that the :class:`~sqlalchemy.engine.interfaces.Dialect` is given a chance to provide a dialect-specific :class:`.Inspector` instance, which may provide additional methods. See the example at :class:`.Inspector`. t inspector(R#R&R(R (tclsR"((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyt from_enginetscCs tj|S(N(R R*(R"((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyt_inspscCs |jjS(sReturn the default schema name presented by the dialect for the current engine's database user. E.g. this is typically ``public`` for PostgreSQL and ``dbo`` for SQL Server. (R&tdefault_schema_name(R((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyR,s cCs2t|jdr.|jj|jd|jSgS(s!Return all schema names. tget_schema_namesR (R#R&R-R"R (R((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyR-s torder_bys1.0sThe :paramref:`get_table_names.order_by` parameter is deprecated and will be removed in a future release. Please refer to :meth:`.Inspector.get_sorted_table_and_fkc_names` for a more comprehensive solution to resolving foreign key cycles between tables.cCst|jdr6|jj|j|d|j}n|jj|}|dkrg}xU|D]M}xD|j||D]0}||dkrz|j|d|fqzqzWqaWt t j ||}n|S(sReturn all table names in referred to within a particular schema. The names are expected to be real tables only, not views. Views are instead returned using the :meth:`.Inspector.get_view_names` method. :param schema: Schema name. If ``schema`` is left at ``None``, the database's default schema is used, else the named schema is searched. If the database does not support named schemas, behavior is undefined if ``schema`` is not passed as ``None``. For special quoting, use :class:`.quoted_name`. :param order_by: Optional, may be the string "foreign_key" to sort the result on foreign key dependencies. Does not automatically resolve cycles, and will raise :class:`.CircularDependencyError` if cycles exist. .. seealso:: :meth:`.Inspector.get_sorted_table_and_fkc_names` :attr:`.MetaData.sorted_tables` tget_table_namesR t foreign_keytreferred_table( R#R&R/R"R R!t table_namestget_foreign_keystappendtlistR tsort(RRR.ttnamesttuplesttnametfkey((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyR/s%   "c st|jdr6|jj|j|d|j}n|jj|}t}t}i}x|D]z}|j||}tg|D]}|d^q||siN(R#R&R/R"R R!R2tsetR3taddR5R R6RtCircularDependencyErrortedgestremovetupdatet differenceR( RRR7R8tremaining_fkcstfknames_for_tableR9tfkeystfkR:tcandidate_sortterr((R=sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pytget_sorted_table_and_fkc_namess0    ' " #&cCs|jj|jd|jS(sreturn a list of temporary table names for the current bind. This method is unsupported by most dialects; currently only SQLite implements it. .. versionadded:: 1.0.0 R (R&tget_temp_table_namesR"R (R((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyRLs cCs|jj|jd|jS(sreturn a list of temporary view names for the current bind. This method is unsupported by most dialects; currently only SQLite implements it. .. versionadded:: 1.0.0 R (R&tget_temp_view_namesR"R (R((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyRMs cKs;t|jdr7|jj|j||d|j|SiS(sReturn a dictionary of options specified when the table of the given name was created. This currently includes some options that apply to MySQL tables. :param table_name: string name of the table. For special quoting, use :class:`.quoted_name`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. tget_table_optionsR (R#R&RNR"R (Rt table_nameRR((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyRN*s cCs|jj|j|d|jS(sReturn all view names in `schema`. :param schema: Optional, retrieve names from a non-default schema. For special quoting, use :class:`.quoted_name`. R (R&tget_view_namesR"R (RR((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyRP>s cCs"|jj|j||d|jS(sReturn definition for `view_name`. :param schema: Optional, retrieve names from a non-default schema. For special quoting, use :class:`.quoted_name`. R (R&tget_view_definitionR"R (Rt view_nameR((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyRQJs cKse|jj|j||d|j|}x7|D]/}|d}t|ts.||dhs(RR?R"R&tschema_for_objectR;tdicttreflection_optionsRNR_t_validate_dialect_kwargsRtpy2kR tstrtdecodetencodingtFalseRTtTruet_reflect_columnRtNoSuchTableErrort _reflect_pkt _reflect_fkt_reflect_indexest_reflect_unique_constraintst_reflect_check_constraintst_reflect_table_comment(RR`tinclude_columnstexclude_columnst resolve_fkst _extend_onR&RRORcttbl_optst found_tabletcols_by_orig_nametcol_d((R`sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyt reflecttable:s        c sd}|jj||d}|r<||ksN|rR||krRdSd}tfddddddd gD} d kr| jd ng} jd dk rCd } t| tjj rt j | d t } n7t| t j s3t j tjd d t } n| j| nd krb|j| nt j||| | ||<} | j|jkrt | _n|j| dS(NR;RSc3s+|]!}|kr||fVqdS(N((R R(Rz(sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pys stnullablet autoincrementtquotetinfoRtcommenttdialect_optionstdefaultt _reflectedtsequence(tdispatchtcolumn_reflectRbRCRRR Rtelementst TextClauset sa_schemat DefaultClauseRjt FetchedValuettextR4t_reflect_col_sequencetColumnRt primary_keyt append_column( RR`RzRsRtRyt orig_nameR;RWtcol_kwtcolargsRtcol((RzsO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyRksB        cCs{d|krw|d}tj|ddd}d|krK|d|_nd|krg|d|_n|j|ndS(NRR;itstartt increment(RtSequenceRRR4(RRzRtseqR((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyRs    c Cs|j|||j}|rg|dD](}||kr)||kr)||^q)}|jd|j_|jj|ndS(NRXR;(RYR_RRR;t_reload( RRORR`RyRttpk_constpktpk_cols((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyRms(c  Cs|j|||j} x| D]} | d} g| dD]%} | |krY|| jn| ^q:} |rt| j|rqn| d}| d}| d}g}|dk r#|rtj||jdt d|d|j d ||nx|D]%}|j d j |||gqWnj|r`tj||jdt d|j dtj d ||nx*|D]"}|j d j ||gqgWd | kr| d }ni}|jtj| || d t |qWdS( NR;RXtreferred_schemaR1treferred_columnstautoloadRt autoload_withRvt.toptionst link_to_name(R3R_RR>t intersectionRRtTabletmetadataRjR"R4tjoint BLANK_SCHEMAtappend_constrainttForeignKeyConstraint(RRORR`RyRtRuRvRcRGtfkey_dtconnametcRXRR1RtrefspectcolumnR((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyRns^   3                  tasctdesct nullsfirstt nullslastc Cs|j||}x|D]} | d} | d} | jdi} | d} | jdd}| jdi}| jd}|rt| j| rtjd |d j| fqn|rqng}x| D]}y'||kr||n |j|}Wn.tk r:tjd |||fqnX| j|d }x2|j D]'\}}||krW||}qWqWW|j |qWt j | d ||t t|jd| fgqWdS(NR;t column_namestcolumn_sortingtuniqueRStindexRtduplicates_constraints5Omitting %s key for (%s), key covers omitted columns.s, s5%s key '%s' was not located in columns for table '%s't_table((R[RR>tissubsetRtwarnRRtKeyErrort_index_sort_exprsR4RtIndexRbR5R(RRORR`RyRsRtRctindexestindex_dR;tcolumnsRRtflavorRt duplicatestidx_colsRtidx_colt c_sortingRtop((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyRogsF        cCs=y|j||}Wntk r*dSXx |D]} | d} | d} | jd} |rt| j| rtjddj| q2n| rq2ng} xm| D]e}y'||kr||n |j|}Wn(t k rtjd||fqX| j |qW|j t j d| | q2WdS(NR;Rtduplicates_indexsDOmitting unique constraint key for (%s), key covers omitted columns.s, sDunique constraint key '%s' was not located in columns for table '%s'(R\tNotImplementedErrorRR>RRRRRRR4RRtUniqueConstraint(RRORR`RyRsRtRct constraintstconst_dRRRtconstrained_colsRtconstrained_col((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyRps6       c CsVy|j||}Wntk r*dSXx$|D]} |jtj| q2WdS(N(R^RRRtCheckConstraint( RRORR`RyRsRtRcRR((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyRqs   cCsDy|j||}Wntk r*dSX|jdd|_dS(NR(R]RRRR(RRORR`Rct comment_dict((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyRrs  (s1.0sThe :paramref:`get_table_names.order_by` parameter is deprecated and will be removed in a future release. Please refer to :meth:`.Inspector.get_sorted_table_and_fkc_names` for a more comprehensive solution to resolving foreign key cycles between tables.N((0Rt __module__t__doc__R't classmethodR*Rt _inspectsRR+tpropertyR,R-Rtdeprecated_paramsRR/RKRLRMRNRPRQRTRRZRYR3R[R\R]R^RjR{RkRRmRnRtasc_optdesc_opt nullsfirst_opt nullslast_opRRoRpRqRr(((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyR =sT  * 8  (  # (    9  I    : 3 N(RtbaseRtRRRRRRRt sql.type_apiRRR t decoratorRtobjectR (((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyts