U aQ@sdZddlmZddlmZdZGdddeZGdddeeZGd d d eZ Gd d d e Z Gd dde Z Gddde Z Gddde Z GdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdd d eZGd!d"d"eZGd#d$d$eZGd%d&d&eZGd'd(d(eZGd)d*d*eeZGd+d,d,eZGd-d.d.eZGd/d0d0eZGd1d2d2eZGd3d4d4eZGd5d6d6eZ Gd7d8d8eZ!Gd9d:d:eZ"Gd;d<dd>eZ$Gd?d@d@eZ%GdAdBdBeZ&GdCdDdDe&Z'GdEdFdFe'Z(GdGdHdHe'Z)GdIdJdJe)Z*GdKdLdLe)Z+GdMdNdNe)Z,GdOdPdPe)Z-GdQdRdRe)Z.GdSdTdTe)Z/GdUdVdVee0Z1GdWdXdXe1Z2GdYdZdZe2Z3Gd[d\d\e4Z5Gd]d^d^ee6Z7dS)_zExceptions used with SQLAlchemy. The base exception class is :exc:`.SQLAlchemyError`. Exceptions which are raised as a result of DBAPI exceptions are all subclasses of :exc:`.DBAPIError`. ) _preloaded)compatNcs,eZdZdZdZfddZddZZS)HasDescriptionCodezDhelper which adds 'code' as an attribute and '_code_str' as a methodNcs0|dd}|dk r||_tt|j||dS)Ncode)poprsuperr__init__)selfargkwr __class__OC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-nyjtotrf\sqlalchemy\exc.pyrs zHasDescriptionCode.__init__cCs|js dSdt|jfSdS)Nz:(Background on this error at: https://sqlalche.me/e/%s/%s))r_version_tokenr rrr _code_str!szHasDescriptionCode._code_str)__name__ __module__ __qualname____doc__rrr __classcell__rrr rrs rc@s6eZdZdZejfddZddZddZdd Z d S) SQLAlchemyErrorzGeneric error class.cCsft|jdkrX|jd}|r6t|tjr6t|d}ntjs@|sJt|}n t|}|St|jSdS)Nrzutf-8) lenargs isinstancerZ binary_typesZdecode_backslashreplacepy3kstr text_type)r as_unicodetextrrr_message2s    zSQLAlchemyError._messagecCs$||}|jr d||f}|SNz%s %s)r#rr)r r!messagerrr _sql_messageVs zSQLAlchemyError._sql_messagecCs |tjSN)r&rrrrrr__str__^szSQLAlchemyError.__str__cCs |jddS)NTr!)r&rrrr __unicode__aszSQLAlchemyError.__unicode__N) rrrrrrr#r&r(r*rrrrr/s $rc@seZdZdZdS) ArgumentErrorzRaised when an invalid or conflicting function argument is supplied. This error generally corresponds to construction time state errors. Nrrrrrrrrr+esr+cs eZdZdZfddZZS)ObjectNotExecutableErrorzqRaised when an object is passed to .execute() that can't be executed as SQL. .. versionadded:: 1.1 cstt|d|dS)NzNot an executable object: %r)rr-r)r targetr rrrus z!ObjectNotExecutableError.__init__)rrrrrrrrr rr-msr-c@seZdZdZdS)NoSuchModuleErrorzpRaised when a dynamically-loaded module (usually a database dialect) of a particular name cannot be located.Nr,rrrrr/{sr/c@seZdZdZdS)NoForeignKeysErrorzURaised when no foreign keys can be located between two selectables during a join.Nr,rrrrr0sr0c@seZdZdZdS)AmbiguousForeignKeysErrorzhRaised when more than one foreign key matching can be located between two selectables during a join.Nr,rrrrr1sr1c@s"eZdZdZdddZddZdS)CircularDependencyErrora Raised by topological sorts when a circular dependency is detected. There are two scenarios where this error occurs: * In a Session flush operation, if two objects are mutually dependent on each other, they can not be inserted or deleted via INSERT or DELETE statements alone; an UPDATE will be needed to post-associate or pre-deassociate one of the foreign key constrained values. The ``post_update`` flag described at :ref:`post_update` can resolve this cycle. * In a :attr:`_schema.MetaData.sorted_tables` operation, two :class:`_schema.ForeignKey` or :class:`_schema.ForeignKeyConstraint` objects mutually refer to each other. Apply the ``use_alter=True`` flag to one or both, see :ref:`use_alter`. NcCsJ|dkr&|dddd|D7}n|}tj|||d||_||_dS)Nz (%s)z, css|]}t|VqdSr')repr).0srrr sz3CircularDependencyError.__init__..r)joinrrcyclesedges)r r%r9r:msgrrrrrs z CircularDependencyError.__init__cCs|jd|j|j|jdffSNr)r r9r:rrrrr __reduce__sz"CircularDependencyError.__reduce__)NNrrrrrr=rrrrr2s r2c@seZdZdZdS) CompileErrorz2Raised when an error occurs during SQL compilationNr,rrrrr?sr?cs&eZdZdZdZdfdd ZZS)UnsupportedCompilationErrorzRaised when an operation is not supported by the given compiler. .. seealso:: :ref:`faq_sql_expression_string` :ref:`error_l7de` Zl7deNcs*tt|d|||rd|ndfdS)Nz-Compiler %r can't render element of type %s%sz: %sr)rr@r)r compilerZ element_typer%r rrrs  z$UnsupportedCompilationError.__init__)N)rrrrrrrrrr rr@s r@c@seZdZdZdS)IdentifierErrorz;Raised when a schema name is beyond the max character limitNr,rrrrrBsrBc@seZdZdZdZdS)DisconnectionErroraA disconnect is detected on a raw DB-API connection. This error is raised and consumed internally by a connection pool. It can be raised by the :meth:`_events.PoolEvents.checkout` event so that the host pool forces a retry; the exception will be caught three times in a row before the pool gives up and raises :class:`~sqlalchemy.exc.InvalidRequestError` regarding the connection attempt. FNrrrrZinvalidate_poolrrrrrCs rCc@seZdZdZdZdS)InvalidatePoolErroraRaised when the connection pool should invalidate all stale connections. A subclass of :class:`_exc.DisconnectionError` that indicates that the disconnect situation encountered on the connection probably means the entire pool should be invalidated, as the database has been restarted. This exception will be handled otherwise the same way as :class:`_exc.DisconnectionError`, allowing three attempts to reconnect before giving up. .. versionadded:: 1.2 TNrDrrrrrEsrEc@seZdZdZdS) TimeoutErrorz@Raised when a connection pool times out on getting a connection.Nr,rrrrrFsrFc@seZdZdZdS)InvalidRequestErrorzvSQLAlchemy was asked to do something it can't do. This error generally corresponds to runtime state errors. Nr,rrrrrGsrGc@seZdZdZdS)NoInspectionAvailablezaA subject passed to :func:`sqlalchemy.inspection.inspect` produced no context for inspection.Nr,rrrrrHsrHc@seZdZdZdS)PendingRollbackErrorzlA transaction has failed and needs to be rolled back before continuing. .. versionadded:: 1.4 Nr,rrrrrIsrIc@seZdZdZdS)ResourceClosedErrorzcAn operation was requested from a connection, cursor, or other object that's in a closed state.Nr,rrrrrJsrJc@seZdZdZdS)NoSuchColumnErrorz1A nonexistent column is requested from a ``Row``.Nr,rrrrrKsrKc@seZdZdZdS) NoResultFoundzA database result was required but none was found. .. versionchanged:: 1.4 This exception is now part of the ``sqlalchemy.exc`` module in Core, moved from the ORM. The symbol remains importable from ``sqlalchemy.orm.exc``. Nr,rrrrrL srLc@seZdZdZdS)MultipleResultsFounda A single database result was required but more than one were found. .. versionchanged:: 1.4 This exception is now part of the ``sqlalchemy.exc`` module in Core, moved from the ORM. The symbol remains importable from ``sqlalchemy.orm.exc``. Nr,rrrrrMsrMc@seZdZdZdS)NoReferenceErrorzDRaised by ``ForeignKey`` to indicate a reference cannot be resolved.Nr,rrrrrN srNc@seZdZdZdZdS) AwaitRequiredzjError raised by the async greenlet spawn if no async operation was awaited when it required one. Zxd1rNrrrrrrrrrrO$srOc@seZdZdZdZdS)MissingGreenletzkError raised by the async greenlet await\_ if called while not inside the greenlet spawn context. Zxd2sNrPrrrrrQ-srQc@s eZdZdZddZddZdS)NoReferencedTableErrorzQRaised by ``ForeignKey`` when the referred ``Table`` cannot be located. cCst||||_dSr')rNr table_name)r r%tnamerrrr<s zNoReferencedTableError.__init__cCs|j|jd|jffSr<)r rrSrrrrr=@sz!NoReferencedTableError.__reduce__Nr>rrrrrR6srRc@s eZdZdZddZddZdS)NoReferencedColumnErrorzRRaised by ``ForeignKey`` when the referred ``Column`` cannot be located. cCst||||_||_dSr')rNrrS column_name)r r%rTcnamerrrrJs z NoReferencedColumnError.__init__cCs|j|jd|j|jffSr<)r rrSrVrrrrr=Osz"NoReferencedColumnError.__reduce__Nr>rrrrrUDsrUc@seZdZdZdS)NoSuchTableErrorz7Table does not exist or is not visible to a connection.Nr,rrrrrXVsrXc@seZdZdZdS)UnreflectableTableErrorzUTable exists but can't be reflected for some reason. .. versionadded:: 1.2 Nr,rrrrrYZsrYc@seZdZdZdS)UnboundExecutionErrorzASQL was attempted without a database connection to execute it on.Nr,rrrrrZbsrZc@seZdZdZdS) DontWrapMixina8A mixin class which, when applied to a user-defined Exception class, will not be wrapped inside of :exc:`.StatementError` if the error is emitted within the process of executing a statement. E.g.:: from sqlalchemy.exc import DontWrapMixin class MyCustomException(Exception, DontWrapMixin): pass class MySpecialType(TypeDecorator): impl = String def process_bind_param(self, value, dialect): if value == 'invalid': raise MyCustomException("invalid!") Nr,rrrrr[fsr[c@sLeZdZdZdZdZdZdZd ddZddZ dd Z e d d d Z dS)StatementErroravAn error occurred during execution of a SQL statement. :class:`StatementError` wraps the exception raised during execution, and features :attr:`.statement` and :attr:`.params` attributes which supply context regarding the specifics of the statement which had an issue. The wrapped exception object is available in the :attr:`.orig` attribute. NFcCs8tj|||d||_||_||_||_||_g|_dS)Nr7)rr statementparamsorigismultihide_parametersdetail)r r%r]r^r_rarr`rrrrs zStatementError.__init__cCs|j|dSr')rbappend)r r;rrr add_detailszStatementError.add_detailcCs&|j|jd|j|j|j|j|jffSr<)r rr]r^r_rar`rrrrr=szStatementError.__reduce__zsqlalchemy.sql.utilcCstjj}|j|dg}|jr|s8tjs8dt|j}n d|j}|||j r|j rd|dn"|j |j d|j d}|d|| }|r||ddd |jD|S) Nr)z [SQL: %s]z3[SQL parameters hidden due to hide_parameters=True] )r`z[parameters: %r] cSsg|] }d|qS)z(%s)r)r4Zdetrrr sz/StatementError._sql_message..)rZ preloadedZsql_utilr#r]rrZsafe_bytestringrcr^raZ _repr_paramsr`rr8rb)r r!utildetailsZ stmt_detailZ params_reprZcode_strrrrr&s0    zStatementError._sql_message)FNN)rrrrr]r^r_r`rrdr=rZpreload_moduler&rrrrr\|s   r\c@s4eZdZdZdZed ddZddZd d d ZdS) DBAPIErrora Raised when the execution of a database operation fails. Wraps exceptions raised by the DB-API underlying the database operation. Driver-specific implementations of the standard DB-API exception types are wrapped by matching sub-types of SQLAlchemy's :class:`DBAPIError` when possible. DB-API's ``Error`` type maps to :class:`DBAPIError` in SQLAlchemy, otherwise the names are identical. Note that there is no guarantee that different DB-API implementations will raise the same exception type for any given error condition. :class:`DBAPIError` features :attr:`~.StatementError.statement` and :attr:`~.StatementError.params` attributes which supply context regarding the specifics of the statement which had an issue, for the typical case when the error was raised within the context of emitting a SQL statement. The wrapped exception object is available in the :attr:`~.StatementError.orig` attribute. Its type and properties are DB-API implementation specific. ZdbapiFNc Cst|trt|trt|tr"|S|dk rt|trh|rhtd|jj|jj|j df|||||j |dSt||s|rtd|jj|jj|f|||||dSt } |jj D]>} | j} |r|j | | } | | krt| | tr| | }qq|||||||j |dS)N (%s.%s) %sr)rarr`)rar`)connection_invalidatedrarr`)r BaseException Exceptionr[rr\r rrrrglobals__mro__Zdbapi_exception_translation_mapget issubclassrj) clsr]r^r_Zdbapi_base_errrarldialectr`globZsuper_namerrrinstancesr zDBAPIError.instancecCs"|j|j|j|j|j|j|jffSr')r r]r^r_rarlr`rrrrr=5szDBAPIError.__reduce__c Csrz t|}Wn.tk r:} zdt| }W5d} ~ XYnXtj|d|jj|jj|f||||||d||_dS)Nz.Error in str() of DB-API-generated exception: rk)rr`)rrnr\rr rrrl) r r]r^r_rarlrr`r"errrrBs"   zDBAPIError.__init__)FFNN)FFNN) rrrrr classmethodrwr=rrrrrrjs Hrjc@seZdZdZdZdS)InterfaceErrorzWraps a DB-API InterfaceError.Zrvf5NrPrrrrrz^srzc@seZdZdZdZdS) DatabaseErrorzWraps a DB-API DatabaseError.Z4xp6NrPrrrrr{dsr{c@seZdZdZdZdS) DataErrorzWraps a DB-API DataError.Z9h9hNrPrrrrr|jsr|c@seZdZdZdZdS)OperationalErrorz Wraps a DB-API OperationalError.Ze3q8NrPrrrrr}psr}c@seZdZdZdZdS)IntegrityErrorzWraps a DB-API IntegrityError.ZgkpjNrPrrrrr~vsr~c@seZdZdZdZdS) InternalErrorzWraps a DB-API InternalError.Z2j85NrPrrrrr|src@seZdZdZdZdS)ProgrammingErrorz Wraps a DB-API ProgrammingError.Zf405NrPrrrrrsrc@seZdZdZdZdS)NotSupportedErrorz!Wraps a DB-API NotSupportedError.Ztw8gNrPrrrrrsrcs$eZdZdZdZfddZZS)SADeprecationWarningz$Issued for usage of deprecated APIs.Ncs(tt|}|jr$d||f}|Sr$)rrr(rr)r r%r rrr(szSADeprecationWarning.__str__rrrrdeprecated_sincer(rrrr rrsrcs$eZdZdZdZfddZZS)RemovedIn20WarningzIssued for usage of APIs specifically deprecated in SQLAlchemy 2.0. .. seealso:: :ref:`error_b8d9`. :ref:`deprecation_20_mode` z1.4cstt|dS)Nz> (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9))rrr(rr rrr(s zRemovedIn20Warning.__str__rrrr rrs rc@seZdZdZdS)MovedIn20WarningzASubtype of RemovedIn20Warning to indicate an API that moved only.Nr,rrrrrsrc@seZdZdZdZdS)SAPendingDeprecationWarningz}A similar warning as :class:`_exc.SADeprecationWarning`, this warning is not used in modern versions of SQLAlchemy. N)rrrrrrrrrrsrc@seZdZdZdS) SAWarningzIssued at runtime.Nr,rrrrrsr)8rrhrrrobjectrrnrr+r-r/r0r1r2r?r@rBrCrErFrGrHrIrJKeyErrorrKrLrMrNrOrQrRrUrXrYrZr[r\rjrzr{r|r}r~rrrDeprecationWarningrrrPendingDeprecationWarningrRuntimeWarningrrrrrsb  6      W