U a*@sdZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd l m Z dd l mZdd l mZdd l mZdd l mZddl mZddl mZddl mZddl mZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%ddlm&Z&ddlm'Z'dd lm(Z(dd!l)m*Z*dd"l)m+Z+dd#lm,Z,dd$lm-Z-dd%lm.Z.dd&lm/Z/dd'lm0Z0dd(l1m2Z2dd)l3m4Z4dd*l3m5Z5dd+l3m6Z6dd,l7m8Z8dd-l7m9Z9dd.l7m:Z:dd/l;mZ>dd1l=m?Z?dd2l=m@Z@dd3l=mAZAdd4l=mBZBdd5l=mCZCdd6l=mDZDdd7l=mEZEdd8lFmGZGdd9lFmHZHdd:lmIZIdd;lJmKZKddlLmOZOdd?lLmPZPdd@lLmQZQddAlLmRZRddBlLmSZSddClLmTZTddDlLmUZUddElLmVZVddFlLmWZWdGdHlmXZYdGdIlmLZZdGdJl[m\Z\dmdLdMZ]e\eQdNZ^e\e9dOZ_eZ`dPdQdRdPZadSdTZbe\e2dUZce\edVZddWdXZedYdZZfeYgfd[d\Zhe\e.d]Ze\ed^Zid_d`ZjejkjlZkejmjlZmejnjlZnejojlZoejpjlZpejqjlZqejrjlZrejsjlZsejtjlZtejujlZuejvjlZvejwjlZwejxjlZxejyjlZyejzjlZzeZ`dadbdcdaZ{e\e4ddZ|ddel}m~Z~ddfl}mZddgl}mZddhl}mZddil}mZddjl}mZdkdlZeedKS)nz Functional constructs for ORM configuration. See the SQLAlchemy object relational tutorial and mapper configuration documentation for an overview of how this module is used. )exc)mapper)strategy_options)AttributeEvent)InstrumentedAttribute)Mapped)QueryableAttribute) QueryContext)as_declarative)declarative_base)declarative_mixin)DeclarativeMeta) declared_attr)has_inherited_table)registry) synonym_for)CompositeProperty)SynonymProperty) IdentityMap) ClassManager) EXT_CONTINUE)EXT_SKIP)EXT_STOP)InspectionAttr)InspectionAttrInfo) MANYTOMANY) MANYTOONE)MapperProperty) NOT_EXTENSION) ONETOMANY)PropComparator)merge_frozen_result) merge_result) class_mapper)configure_mappers)Mapper) reconstructor) validatesColumnProperty) AliasOption) FromStatement)Query)foreign)RelationshipProperty)remote)scoped_session)close_all_sessions)make_transient)make_transient_to_detached)object_session)ORMExecuteState)Session) sessionmaker)SessionTransaction)AttributeState) InstanceState)Load)UOWTransaction)aliased)Bundle)CascadeOptions)join)LoaderCriteriaOption) object_mapper) outerjoin)polymorphic_union) was_deleted) with_parent)with_polymorphic)sqlutil)public_factoryNcKsP|ddr|ddn |dd|dd|ddtfd|i|S)aCreate a new :class:`.Session` with no automation enabled by default. This function is used primarily for testing. The usual route to :class:`.Session` creation is via its constructor or the :func:`.sessionmaker` function. :param bind: optional, a single Connectable to use for all database access in the created :class:`~sqlalchemy.orm.session.Session`. :param \*\*kwargs: optional, passed through to the :class:`.Session` constructor. :returns: an :class:`~sqlalchemy.orm.session.Session` instance The defaults of create_session() are the opposite of that of :func:`sessionmaker`; ``autoflush`` and ``expire_on_commit`` are False, ``autocommit`` is True. In this sense the session acts more like the "classic" SQLAlchemy 0.3 session with these. Usage:: >>> from sqlalchemy.orm import create_session >>> session = create_session() It is recommended to use :func:`sessionmaker` instead of create_session(). futureFZ autocommitTZ autoflushZexpire_on_commitbind)get setdefaultr6)rNkwargsrRXC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-nyjtotrf\sqlalchemy\orm\__init__.pycreate_sessionZs    rTz.ormz.orm.relationshiprelationz!Please use :func:`.relationship`.cOs t||S)z#A synonym for :func:`relationship`. relationship)argkwrRrRrSrUscKsd|d<t|f|S)aiConstruct a dynamically-loading mapper property. This is essentially the same as using the ``lazy='dynamic'`` argument with :func:`relationship`:: dynamic_loader(SomeClass) # is the same as relationship(SomeClass, lazy="dynamic") See the section :ref:`dynamic_relationship` for more details on dynamic loading. dynamicZlazyrV)ZargumentrYrRrRrSdynamic_loadersr[z.orm.column_propertyz.orm.compositecKs||fS)aCreate a back reference with explicit keyword arguments, which are the same arguments one can send to :func:`relationship`. Used with the ``backref`` keyword argument to :func:`relationship` in place of a string argument, e.g.:: 'items':relationship( SomeItem, backref=backref('parent', lazy='subquery')) .. seealso:: :ref:`relationships_backref` rR)namerQrRrRrSbackrefsr]cOst|ddi|S)aIndicate a column-based mapped attribute that by default will not load unless accessed. :param \*columns: columns to be mapped. This is typically a single :class:`_schema.Column` object, however a collection is supported in order to support multiple columns mapped under the same attribute. :param raiseload: boolean, if True, indicates an exception should be raised if the load operation is to take place. .. versionadded:: 1.4 .. seealso:: :ref:`deferred_raiseload` :param \**kw: additional keyword arguments passed to :class:`.ColumnProperty`. .. seealso:: :ref:`deferred` deferredTr()columnsrYrRrRrSr^sr^cCst|}d|_|S)aIndicate an attribute that populates from a query-time SQL expression. :param default_expr: Optional SQL expression object that will be used in all cases if not assigned later with :func:`_orm.with_expression`. E.g.:: from sqlalchemy.sql import literal class C(Base): #... my_expr = query_expression(literal(1)) .. versionadded:: 1.3.18 .. versionadded:: 1.2 .. seealso:: :ref:`mapper_querytime_expression` ))query_expressionT)r)Z strategy_key)Z default_exprproprRrRrSr`sr`z .orm.mapperz .orm.synonymcCsttddS)aRemove all mappers from all classes. .. versionchanged:: 1.4 This function now locates all :class:`_orm.registry` objects and calls upon the :meth:`_orm.registry.dispose` method of each. This function removes all instrumentation from classes and disposes of their associated mappers. Once called, the classes are unmapped and can be later re-mapped with new mappers. :func:`.clear_mappers` is *not* for normal use, as there is literally no valid usage for it outside of very specific testing scenarios. Normally, mappers are permanent structural components of user-defined classes, and are never discarded independently of their class. If a mapped class itself is garbage collected, its mapper is automatically disposed of as well. As such, :func:`.clear_mappers` is only for usage in test suites that re-use the same classes with different mappings, which is itself an extremely rare use case - the only such use case is in fact SQLAlchemy's own test suite, and possibly the test suites of other ORM extension libraries which intend to test various combinations of mapper construction upon a fixed set of classes. FN) mapperlibZ_dispose_registriesZ_all_registriesrRrRrRrS clear_mapperssrc eagerloadz#Please use :func:`_orm.joinedload`.cOs t||S)z#A synonym for :func:`joinedload()`.) joinedload)argsrQrRrRrSrd&sz.orm.contains_alias)AttributeEvents) MapperEvents)InstanceEvents)InstrumentationEvents) QueryEvents) SessionEventscszddlm}ddlm}ddlm}ddlm}ddlddlmatfd d |Da t j d t j d dS) NrHrJr)rZ)events)loading) AppenderQueryc3s*|]"\}}|ds|s|VqdS)_N) startswithismodule).0r\objZ_inspectrRrS Bs z__go..zsqlalchemy.ormzsqlalchemy.ext) rKrZrmrninspectrpsorteditems__all___sa_utilZ preloadedZ import_prefix)ZlclsZsa_utilrZrmrnrRrvrS__go7s       r~)N)__doc__rxrrrbr attributesrrrrcontextr Zdecl_apir r r r rrrrZdescriptor_propsrridentityrZinstrumentationrZ interfacesrrrrrrrrrrr rnr!r"r#r$r%r&r'Z propertiesr)queryr*r+r,Z relationshipsr-r.r/Zscopingr0sessionr1r2r3r4r5r6r7r8stater9r:r;Z unitofworkr<rKr=r>r?r@rArBrCrDrErFrGrIZ_sqlr}Zutil.langhelpersrLrTZwith_loader_criteriarWZ deprecated_20rUr[Zcolumn_propertyZ compositer]r^nullr`ZsynonymrcreZ _unbound_fnZcontains_eagerdeferZundeferZ undefer_groupZwith_expression load_onlyZlazyloadZ subqueryloadZ selectinloadZ immediateloadZnoloadZ raiseloadZ defaultloadZselectin_polymorphicrdZcontains_aliasrmrgrhrirjrkrlr~localsrRrRrRrSs                                                                         *