U kf]@sUdZddlmZddlZddlmZddlmZddlmZddlmZddlmZdd lm Z dd lm Z d d l m Z d d l m Zejrd dlmZd dlmZd dlmZd dlmZd dlmZejrded<ndZGdddZGdddeeZGdddeZGdddeZGdddeZGdd d eZ Gd!d"d"eZ!Gd#d$d$eZ"Gd%d&d&eZ#Gd'd(d(eZ$Gd)d*d*eZ%Gd+d,d,e%Z&Gd-d.d.eZ'Gd/d0d0eZ(Gd1d2d2e(Z)Gd3d4d4eZ*Gd5d6d6eZ+Gd7d8d8e+Z,Gd9d:d:e+Z-Gd;d<dd>e+Z/Gd?d@d@e+e0Z1GdAdBdBe+Z2GdCdDdDe+Z3GdEdFdFe+Z4GdGdHdHe+Z5GdIdJdJe+Z6GdKdLdLe4Z7GdMdNdNe4Z8GdOdPdPe+Z9GdQdRdRe+Z:GdSdTdTe+Z;GdUdVdVZGd[d\d\e>Z?Gd]d^d^e>Z@Gd_d`d`e@ZAGdadbdbe@ZBGdcdddde@ZCGdedfdfe@ZDGdgdhdhe@ZEGdidjdje@ZFGdkdldleGZHGdmdndneeIZJGdodpdpeJZKGdqdrdreKZLGdsdtdteKZMGdudvdveNZOGdwdxdxeePZQdS)yzExceptions 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`. ) annotationsN)Any)List)Optional)overload)Tuple)Type)Union)compat) preloaded)_AnyExecuteParams)Dialect)Compiled) TypeCompiler) ClauseElementstr_version_tokencsZeZdZUdZdZded<dddfdd Zd Zd d d d Zd d fdd Z Z S)HasDescriptionCodezDhelper which adds 'code' as an attribute and '_code_str' as a methodN Optional[str]coder)argkwcs,|dd}|dk r||_tj||dS)Nr)poprsuper__init__)selfrrr __class__>/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/exc.pyr0s zHasDescriptionCode.__init__errorrreturncCs*|js dSd|jdtd|jdSdS)Nz(Background on this z at: https://sqlalche.me/e//))r _what_are_werrrrr _code_str8szHasDescriptionCode._code_strcs$t}|jr d||f}|SNz%s %s)r__str__rr)rmessagerrr r+As zHasDescriptionCode.__str__) __name__ __module__ __qualname____doc__r__annotations__rr'r)r+ __classcell__rrrr r+s   rc@s:eZdZdZddddZddddZdddd Zd S) SQLAlchemyErrorzGeneric error class.rr"cCsJt|jdkr<|jd}t|tr0t|d}nt|}|St|jSdS)Nr rzutf-8)lenargs isinstancebytesr Zdecode_backslashreplacer)rZarg_texttextrrr _messageKs   zSQLAlchemyError._messagecCs"|}|jrd||f}|Sr*)r:rr)r,rrr _sql_messagejszSQLAlchemyError._sql_messagecCs|SN)r;r(rrr r+rszSQLAlchemyError.__str__N)r.r/r0r1r:r;r+rrrr r4Hsr4c@seZdZdZdS) ArgumentErrorzRaised when an invalid or conflicting function argument is supplied. This error generally corresponds to construction time state errors. Nr.r/r0r1rrrr r=vsr=c@seZdZdZdS)DuplicateColumnErrorza Column is being added to a Table that would replace another Column, without appropriate parameters to allow this in place. .. versionadded:: 2.0.0b4 Nr>rrrr r?~sr?cs4eZdZdZddfdd Zdddd ZZS) ObjectNotExecutableErrorzVRaised when an object is passed to .execute() that can't be executed as SQL. r)targetcstd|||_dS)NzNot an executable object: %r)rrrA)rrArrr rsz!ObjectNotExecutableError.__init__Union[str, Tuple[Any, ...]]r"cCs|j|jffSr<)rrAr(rrr __reduce__sz#ObjectNotExecutableError.__reduce__)r.r/r0r1rrCr3rrrr r@sr@c@seZdZdZdS)NoSuchModuleErrorzpRaised when a dynamically-loaded module (usually a database dialect) of a particular name cannot be located.Nr>rrrr rDsrDc@seZdZdZdS)NoForeignKeysErrorzURaised when no foreign keys can be located between two selectables during a join.Nr>rrrr rEsrEc@seZdZdZdS)AmbiguousForeignKeysErrorzhRaised when more than one foreign key matching can be located between two selectables during a join.Nr>rrrr rFsrFc@seZdZdZdS)ConstraintColumnNotFoundErrorzraised when a constraint refers to a string column name that is not present in the table being constrained. .. versionadded:: 2.0 Nr>rrrr rGsrGc@s6eZdZdZd ddddddddZd d d d ZdS)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`. Nrrr)r-cyclesedgesmsgrcCsJ|dkr&|dddd|D7}n|}tj|||d||_||_dS)Nz (%s)z, css|]}t|VqdSr<)repr).0srrr sz3CircularDependencyError.__init__..r)joinr4rrIrJ)rr-rIrJrKrrrr rs z CircularDependencyError.__init__rBr"cCs2|jd|j|j|jdf|jdk r,d|jinifS)Nrr)rrIrJr6rr(rrr rCsz"CircularDependencyError.__reduce__)NNr.r/r0r1rrCrrrr rHs rHc@seZdZdZdS) CompileErrorz2Raised when an error occurs during SQL compilationNr>rrrr rSsrScs>eZdZdZdZdddddfdd Zd d d d ZZS)UnsupportedCompilationErrorzRaised when an operation is not supported by the given compiler. .. seealso:: :ref:`faq_sql_expression_string` :ref:`error_l7de` Zl7deNzUnion[Compiled, TypeCompiler]zType[ClauseElement]r)compiler element_typer-cs8td|||rd|ndf||_||_||_dS)Nz-Compiler %r can't render element of type %s%sz: %sr$)rrrUrVr-)rrUrVr-rrr rsz$UnsupportedCompilationError.__init__rBr"cCs|j|j|j|jffSr<)rrUrVr-r(rrr rCsz&UnsupportedCompilationError.__reduce__)N)r.r/r0r1rrrCr3rrrr rTs  rTc@seZdZdZdS)IdentifierErrorz;Raised when a schema name is beyond the max character limitNr>rrrr rWsrWc@seZdZUdZdZded<dS)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. Fboolinvalidate_poolNr.r/r0r1rZr2rrrr rXs  rXc@seZdZUdZdZded<dS)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 TrYrZNr[rrrr r\ s r\c@seZdZdZdS) TimeoutErrorz@Raised when a connection pool times out on getting a connection.Nr>rrrr r]sr]c@seZdZdZdS)InvalidRequestErrorzvSQLAlchemy was asked to do something it can't do. This error generally corresponds to runtime state errors. Nr>rrrr r^#sr^c@seZdZdZdS)IllegalStateChangeErrorzrAn object that tracks state encountered an illegal state change of some kind. .. versionadded:: 2.0 Nr>rrrr r_+sr_c@seZdZdZdS)NoInspectionAvailablezaA subject passed to :func:`sqlalchemy.inspection.inspect` produced no context for inspection.Nr>rrrr r`4sr`c@seZdZdZdS)PendingRollbackErrorzlA transaction has failed and needs to be rolled back before continuing. .. versionadded:: 1.4 Nr>rrrr ra9srac@seZdZdZdS)ResourceClosedErrorzcAn operation was requested from a connection, cursor, or other object that's in a closed state.Nr>rrrr rbBsrbc@seZdZdZdS)NoSuchColumnErrorz1A nonexistent column is requested from a ``Row``.Nr>rrrr rcGsrcc@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>rrrr rdKsrdc@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>rrrr reWsrec@seZdZUdZded<dS)NoReferenceErrorzDRaised by ``ForeignKey`` to indicate a reference cannot be resolved.r table_nameN)r.r/r0r1r2rrrr rfbs rfc@seZdZdZdZdS) AwaitRequiredzjError raised by the async greenlet spawn if no async operation was awaited when it required one. Zxd1rNr.r/r0r1rrrrr rhhsrhc@seZdZdZdZdS)MissingGreenletzkError raised by the async greenlet await\_ if called while not inside the greenlet spawn context. Zxd2sNrirrrr rjqsrjc@s.eZdZdZdddddZdddd Zd S) NoReferencedTableErrorzQRaised by ``ForeignKey`` when the referred ``Table`` cannot be located. r)r-tnamecCst||||_dSr<)rfrrg)rr-rlrrr rs zNoReferencedTableError.__init__rBr"cCs|j|jd|jffSNr)rr6rgr(rrr rCsz!NoReferencedTableError.__reduce__NrRrrrr rkzsrkc@s0eZdZdZddddddZdddd Zd S) NoReferencedColumnErrorzRRaised by ``ForeignKey`` when the referred ``Column`` cannot be located. r)r-rlcnamecCst||||_||_dSr<)rfrrg column_name)rr-rlrorrr rs z NoReferencedColumnError.__init__rBr"cCs|j|jd|j|jffSrm)rr6rgrpr(rrr rCsz"NoReferencedColumnError.__reduce__NrRrrrr rnsrnc@seZdZdZdS)NoSuchTableErrorz7Table does not exist or is not visible to a connection.Nr>rrrr rqsrqc@seZdZdZdS)UnreflectableTableErrorzUTable exists but can't be reflected for some reason. .. versionadded:: 1.2 Nr>rrrr rrsrrc@seZdZdZdS)UnboundExecutionErrorzASQL was attempted without a database connection to execute it on.Nr>rrrr rssrsc@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>rrrr rtsrtc @seZdZUdZdZded<dZded<dZded<dZd ed <d Z d ed <dddddd dd dddZ dddddZ ddddZ e dddddZdS)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. Nr statementOptional[_AnyExecuteParams]paramszOptional[BaseException]origOptional[bool]ismultiFrYconnection_invalidatedr)r-rvrxryhide_parametersrr{cCs8tj|||d||_||_||_||_||_g|_dS)NrP)r4rrvrxryr{r}detail)rr-rvrxryr}rr{rrr rs zStatementError.__init__None)rKr#cCs|j|dSr<)r~append)rrKrrr add_detailszStatementError.add_detailrBr"c Cs8|j|jd|j|j|j|j|jd|jfd|j ifS)Nrrr~) rr6rvrxryr}__dict__getr{r~r(rrr rCs  zStatementError.__reduce__zsqlalchemy.sql.utilcCstj}|g}|jrdd|j}|||jrd|jrB|dn"|j|jd|jd}|d|| }|rz||d dd|j D|S) Nz [SQL: %s]z3[SQL parameters hidden due to hide_parameters=True] )r{z[parameters: %r] cSsg|] }d|qS)z(%s)r)rMZdetrrr sz/StatementError._sql_message..) _preloadedZsql_utilr:rvrrxr}Z _repr_paramsr{r)rQr~)rutildetailsZ stmt_detailZ params_reprZcode_strrrr r;s(    zStatementError._sql_message)FNN)r.r/r0r1rvr2rxryr{r|rrrCrZpreload_moduler;rrrr rus      ruc @seZdZdZdZeedddddd d d d d d ddZeedddddd d d d dd ddZeedddddd d d d dd ddZed ddddd d d d dd ddZddddZd!dddd d dd dddZ dS)" 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. ZdbapiFNrrw ExceptionzType[Exception]rYzOptional[Dialect]rzru) rvrxrydbapi_base_errr}r|dialectr{r#c CsdSr<r clsrvrxryrr}r|rr{rrr instance2s zDBAPIError.instancertc CsdSr<rrrrr r@s BaseExceptionc CsdSr<rrrrr rNs z#Union[BaseException, DontWrapMixin]c 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)r}rr{)r}r{)r|r}rr{)r7rrrtr4rurr/r.r6rglobals__mro__Zdbapi_exception_translation_mapr issubclassr) rrvrxryrr}r|rr{globZsuper_namerrr r\sr rBr"c Cs4|j|j|j|j|j|j|jd|jfd|j ifS)Nrr~) rrvrxryr}r|rrr{r~r(rrr rCs  zDBAPIError.__reduce__)rvrxryr}r|rr{c Csrz t|}Wn.tk r:} zdt| }W5d} ~ XYnXtj|d|jj|jj|f||||||d||_dS)Nz.Error in str() of DB-API-generated exception: r)rr{)rrrurrr/r.r|) rrvrxryr}r|rr{r9errr rs"   zDBAPIError.__init__)FFNN)FFNN)FFNN)FFNN)FFNN) r.r/r0r1rr classmethodrrCrrrrr rsF$ $ $ "Hrc@seZdZdZdZdS)InterfaceErrorzWraps a DB-API InterfaceError.Zrvf5Nrirrrr rsrc@seZdZdZdZdS) DatabaseErrorzWraps a DB-API DatabaseError.Z4xp6Nrirrrr rsrc@seZdZdZdZdS) DataErrorzWraps a DB-API DataError.Z9h9hNrirrrr rsrc@seZdZdZdZdS)OperationalErrorz Wraps a DB-API OperationalError.Ze3q8Nrirrrr rsrc@seZdZdZdZdS)IntegrityErrorzWraps a DB-API IntegrityError.ZgkpjNrirrrr rsrc@seZdZdZdZdS) InternalErrorzWraps a DB-API InternalError.Z2j85Nrirrrr rsrc@seZdZdZdZdS)ProgrammingErrorz Wraps a DB-API ProgrammingError.Zf405Nrirrrr rsrc@seZdZdZdZdS)NotSupportedErrorz!Wraps a DB-API NotSupportedError.Ztw8gNrirrrr rsrc@seZdZdZdS)SATestSuiteWarningzwarning for a condition detected during tests that is non-fatal Currently outside of SAWarning so that we can work around tools like Alembic doing the wrong thing with warnings. Nr>rrrr rsrc@seZdZUdZdZded<dS)SADeprecationWarningz$Issued for usage of deprecated APIs.Nrdeprecated_sincer.r/r0r1rr2rrrr r s  rcs4eZdZUdZdZded<ddfdd ZZS) Base20DeprecationWarningzIssued for usage of APIs specifically deprecated or legacy in SQLAlchemy 2.0. .. seealso:: :ref:`error_b8d9`. :ref:`deprecation_20_mode` z1.4rrrr"cstdS)Nz> (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9))rr+r(rrr r+"sz Base20DeprecationWarning.__str__)r.r/r0r1rr2r+r3rrrr rs  rc@seZdZdZdS)LegacyAPIWarningzEindicates an API that is in 'legacy' status, a long term deprecation.Nr>rrrr r)src@seZdZdZdS)MovedIn20WarningzASubtype of RemovedIn20Warning to indicate an API that moved only.Nr>rrrr r-src@seZdZUdZdZded<dS)SAPendingDeprecationWarningz}A similar warning as :class:`_exc.SADeprecationWarning`, this warning is not used in modern versions of SQLAlchemy. Nrrrrrrr r1s  rc@seZdZdZdZdS) SAWarningzIssued at runtime.warningN)r.r/r0r1r'rrrr r;sr)Rr1 __future__rtypingrrrrrrr rr r r TYPE_CHECKINGZengine.interfacesr rZ sql.compilerrrZ sql.elementsrr2rrrr4r=r?r@rDrErFrGrHrSrTrWrXr\r]r^r_r`rarbKeyErrorrcrdrerfrhrjrkrnrqrrrsrtrurrrrrrrrrWarningrDeprecationWarningrrrrPendingDeprecationWarningrRuntimeWarningrrrrr s                .  +      Y8