B 4]>@sjdZddlmZGdddeZGdddeZGdddeZGd d d eZGd d d eZGd ddeZ GdddeZ GdddeZ Gddde Z GdddeZ GdddeZGdddeZGdddeZGdddeZGdd d eZGd!d"d"eZGd#d$d$eeZGd%d&d&eZGd'd(d(eZGd)d*d*eZGd+d,d,eZGd-d.d.eZGd/d0d0eZGd1d2d2eZd3ZGd4d5d5eZGd6d7d7eZ Gd8d9d9e Z!Gd:d;d;e Z"Gdd?d?e"Z$Gd@dAdAe"Z%GdBdCdCe"Z&GdDdEdEe"Z'GdFdGdGe"Z(GdHdIdIe)Z*GdJdKdKe+Z,GdLdMdMe-Z.d3S)NzExceptions 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`. )compatcsReZdZdZdZfddZddZejfddZ d d Z d d Z d dZ Z S)SQLAlchemyErrorzGeneric error class.Ncs0|dd}|dk r||_tt|j||dS)Ncode)poprsuperr__init__)selfargkwr) __class__A/opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/exc.pyrs zSQLAlchemyError.__init__cCs|js dSd|jfSdS)Nz6(Background on this error at: http://sqlalche.me/e/%s))r)rr r r _code_strszSQLAlchemyError._code_strcCsNt|jdkr@|jd}|r4t|tjr4t|dS|jdSn t|jSdS)Nrzutf-8)lenargs isinstancerZ binary_typesZdecode_backslashreplacestr)r as_unicodetextr r r _message's    zSQLAlchemyError._messagecCs$||}|jr d||f}|S)Nz%s %s)rrr)rrmessager r r _sql_messageCs zSQLAlchemyError._sql_messagecCs |tjS)N)rrpy3k)rr r r __str__KszSQLAlchemyError.__str__cCs |jddS)NT)r)r)rr r r __unicode__NszSQLAlchemyError.__unicode__)__name__ __module__ __qualname____doc__rrrrrrrrr __classcell__r r )r r rs  rc@seZdZdZdS) ArgumentErrorzRaised when an invalid or conflicting function argument is supplied. This error generally corresponds to construction time state errors. N)rrrr r r r r r"Rsr"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)rtarget)r r r rbs z!ObjectNotExecutableError.__init__)rrrr rr!r r )r r r#Zsr#c@seZdZdZdS)NoSuchModuleErrorzpRaised when a dynamically-loaded module (usually a database dialect) of a particular name cannot be located.N)rrrr r r r r r%hsr%c@seZdZdZdS)NoForeignKeysErrorzURaised when no foreign keys can be located between two selectables during a join.N)rrrr r r r r r&msr&c@seZdZdZdS)AmbiguousForeignKeysErrorzhRaised when more than one foreign key matching can be located between two selectables during a join.N)rrrr r r r r r'rsr'c@s"eZdZdZdddZddZdS)CircularDependencyErroraRaised 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:`.MetaData.sorted_tables` operation, two :class:`.ForeignKey` or :class:`.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|VqdS)N)repr).0sr r r sz3CircularDependencyError.__init__..)r)joinrrcyclesedges)rrr.r/msgrr r r rs z CircularDependencyError.__init__cCs|jd|j|j|jdffS)Nr)r r.r/r)rr r r __reduce__sz"CircularDependencyError.__reduce__)NN)rrrr rr1r r r r r(ws r(c@seZdZdZdS) CompileErrorz2Raised when an error occurs during SQL compilationN)rrrr r r r r r2sr2cs$eZdZdZdZfddZZS)UnsupportedCompilationErrorzRaised when an operation is not supported by the given compiler. .. seealso:: :ref:`faq_sql_expression_string` :ref:`error_l7de` Zl7decstt|d||fdS)Nz+Compiler %r can't render element of type %s)rr3r)rZcompilerZ element_type)r r r rs z$UnsupportedCompilationError.__init__)rrrr rrr!r r )r r r3sr3c@seZdZdZdS)IdentifierErrorz;Raised when a schema name is beyond the max character limitN)rrrr r r r r r4sr4c@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:`.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. FN)rrrr invalidate_poolr r r r r5s r5c@seZdZdZdZdS)InvalidatePoolErroraRaised when the connection pool should invalidate all stale connections. A subclass of :class:`.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:`.DisconnectionError`, allowing three attempts to reconnect before giving up. .. versionadded:: 1.2 TN)rrrr r6r r r r r7s r7c@seZdZdZdS) TimeoutErrorz@Raised when a connection pool times out on getting a connection.N)rrrr r r r r r8sr8c@seZdZdZdS)InvalidRequestErrorzvSQLAlchemy was asked to do something it can't do. This error generally corresponds to runtime state errors. N)rrrr r r r r r9sr9c@seZdZdZdS)NoInspectionAvailablezaA subject passed to :func:`sqlalchemy.inspection.inspect` produced no context for inspection.N)rrrr r r r r r:sr:c@seZdZdZdS)ResourceClosedErrorzcAn operation was requested from a connection, cursor, or other object that's in a closed state.N)rrrr r r r r r;sr;c@seZdZdZdS)NoSuchColumnErrorz6A nonexistent column is requested from a ``RowProxy``.N)rrrr r r r r r<sr<c@seZdZdZdS)NoReferenceErrorzDRaised by ``ForeignKey`` to indicate a reference cannot be resolved.N)rrrr r r r r r=sr=c@s eZdZdZddZddZdS)NoReferencedTableErrorzQRaised by ``ForeignKey`` when the referred ``Table`` cannot be located. cCst||||_dS)N)r=r table_name)rrtnamer r r rs zNoReferencedTableError.__init__cCs|j|jd|jffS)Nr)r rr?)rr r r r1sz!NoReferencedTableError.__reduce__N)rrrr rr1r r r r r>sr>c@s eZdZdZddZddZdS)NoReferencedColumnErrorzRRaised by ``ForeignKey`` when the referred ``Column`` cannot be located. cCst||||_||_dS)N)r=rr? column_name)rrr@Zcnamer r r rs z NoReferencedColumnError.__init__cCs|j|jd|j|jffS)Nr)r rr?rB)rr r r r1sz"NoReferencedColumnError.__reduce__N)rrrr rr1r r r r rAsrAc@seZdZdZdS)NoSuchTableErrorz7Table does not exist or is not visible to a connection.N)rrrr r r r r rCsrCc@seZdZdZdS)UnreflectableTableErrorzUTable exists but can't be reflected for some reason. .. versionadded:: 1.2 N)rrrr r r r r rDsrDc@seZdZdZdS)UnboundExecutionErrorzASQL was attempted without a database connection to execute it on.N)rrrr r r r r rEsrEc@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!") N)rrrr r r r r rFsrFNc@s>eZdZdZdZdZdZd ddZddZddZ 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. NcCs,tj|||d||_||_||_g|_dS)N)r)rr statementparamsorigdetail)rrrHrIrJrr r r rOs zStatementError.__init__cCs|j|dS)N)rKappend)rr0r r r add_detailVszStatementError.add_detailcCs|j|jd|j|j|jffS)Nr)r rrHrIrJ)rr r r r1YszStatementError.__reduce__cCsddlm}|j|dg}|jrr|sqsz/StatementError._sql_message..) Zsqlalchemy.sqlrNrrHrrZsafe_bytestringrLrIZ _repr_paramsrr-rK)rrrNZdetailsZ stmt_detailZ params_reprZcode_strr r r r_s      zStatementError._sql_message)N) rrrr rHrIrJrrMr1rr r r r rG9s  rGc@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|trd|rdtd|jj|jj|j df||||j dSt||s|rtd|jj|jj|f|||St }xH|jj D]<}|j} |r|j | | } | |krt|| tr|| }PqW||||||j dS)Nz (%s.%s) %sr)r)r BaseException ExceptionrFrrGr rrrrglobals__mro__Zdbapi_exception_translation_mapget issubclassrR) clsrHrIrJZdbapi_base_errconnection_invalidatedZdialectZglobZsuper_namer r r instancesD    zDBAPIError.instancecCs|j|j|j|j|jffS)N)r rHrIrJrZ)rr r r r1s zDBAPIError.__reduce__c Csny t|}Wn.tk r:}zdt|}Wdd}~XYnXtj|d|jj|jj|f||||d||_dS)Nz.Error in str() of DB-API-generated exception: z (%s.%s) %s)r)rrTrGrr rrrZ)rrHrIrJrZrrer r r rs zDBAPIError.__init__)FN)FN) rrrr r classmethodr\r1rr r r r rRts 5 rRc@seZdZdZdZdS)InterfaceErrorzWraps a DB-API InterfaceError.Zrvf5N)rrrr rr r r r r_sr_c@seZdZdZdZdS) DatabaseErrorzWraps a DB-API DatabaseError.Z4xp6N)rrrr rr r r r r`sr`c@seZdZdZdZdS) DataErrorzWraps a DB-API DataError.Z9h9hN)rrrr rr r r r rasrac@seZdZdZdZdS)OperationalErrorz Wraps a DB-API OperationalError.Ze3q8N)rrrr rr r r r rbsrbc@seZdZdZdZdS)IntegrityErrorzWraps a DB-API IntegrityError.ZgkpjN)rrrr rr r r r rcsrcc@seZdZdZdZdS) InternalErrorzWraps a DB-API InternalError.Z2j85N)rrrr rr r r r rdsrdc@seZdZdZdZdS)ProgrammingErrorz Wraps a DB-API ProgrammingError.Zf405N)rrrr rr r r r re srec@seZdZdZdZdS)NotSupportedErrorz!Wraps a DB-API NotSupportedError.Ztw8gN)rrrr rr r r r rfsrfc@seZdZdZdS)SADeprecationWarningz*Issued once per usage of a deprecated API.N)rrrr r r r r rgsrgc@seZdZdZdS)SAPendingDeprecationWarningz*Issued once per usage of a deprecated API.N)rrrr r r r r rhsrhc@seZdZdZdS) SAWarningzIssued at runtime.N)rrrr r r r r ri#sri)/r rNrrTrr"r#r%r&r'r(r2r3r4r5r7r8r9r:r;KeyErrorr<r=r>rArCrDrEobjectrFZUnmappedColumnErrorrGrRr_r`rarbrcrdrerfDeprecationWarningrgPendingDeprecationWarningrhRuntimeWarningrir r r r sN ?;t