zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
U
£ý°d ,ã @sbUdZddlmZmZmZmZmZmZddlm    Z    ddl
m Z ddl m Z mZGdd„deƒZGd    d
„d
eƒZGd d „d eƒZGd d„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZeeeeeeeeeeeeeeeeeeeeef
Zeeeeeeeeeeeef Ziaeeefed<d-eeeeeeeffeeeeeefdœd d!„Z d.eee!ee!ee"ed#œd$d%„Z#e$ed&œd'd(„Z%eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed)œZ&ee!efed*<eeeeeeeed+œZ'eeefed,<dS)/zPython exceptions.é)ÚDictÚMappingÚOptionalÚTupleÚTypeÚUnioné)Úget_client_error)Ú
StrOrBytes)Ú
read_bytesÚread_intcs^eZdZdZd
eeeeeeeeefdfeeddœ‡fdd„ Z    edœdd    „Z
‡Z S) ÚErrorz;Exception that is base class for all other error exceptionsN.)ÚmsgÚerrnoÚvaluesÚsqlstateÚreturnc
stƒ ¡||_|j|_|pd|_||_|js¦d|jkrDdkr¦nn^t|jƒ|_|dk    r¸z|j||_Wq¸tk
r¢}z|j›d|›d|_W5d}~XYq¸Xn|js¸d|_|_|jrþ|jdkrþ|j|jdœ}|jrìd}|j|d    <nd
}|jf|Ž|_|j|j|jf|_    dS) NéÿÿÿÿiÐi¸ z  (Warning: ú)z Unknown error)rrz{errno} ({state}): {msg}Ústatez{errno}: {msg})
ÚsuperÚ__init__rÚ    _full_msgrrr    Ú    TypeErrorÚformatÚargs)ÚselfrrrrÚerrÚfieldsÚfmt©Ú    __class__©úMd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\mysql/connector/errors.pyr(s,
 
  (  zError.__init__)rcCs|jS)N)r)rr"r"r#Ú__str__Jsz Error.__str__)NNNN) Ú__name__Ú
__module__Ú __qualname__Ú__doc__rÚstrÚintrrrr$Ú __classcell__r"r"r r#r %sûú"r c@seZdZdZdS)ÚWarningz Exception for important warningsN©r%r&r'r(r"r"r"r#r,Nsr,c@seZdZdZdS)ÚInterfaceErrorz-Exception for errors related to the interfaceNr-r"r"r"r#r.Rsr.c@seZdZdZdS)Ú DatabaseErrorz,Exception for errors related to the databaseNr-r"r"r"r#r/Vsr/c@seZdZdZdS)Ú InternalErrorz-Exception for errors internal database errorsNr-r"r"r"r#r0Zsr0c@seZdZdZdS)ÚOperationalErrorz8Exception for errors related to the database's operationNr-r"r"r"r#r1^sr1c@seZdZdZdS)ÚProgrammingErrorz'Exception for errors programming errorsNr-r"r"r"r#r2bsr2c@seZdZdZdS)ÚIntegrityErrorz3Exception for errors regarding relational integrityNr-r"r"r"r#r3fsr3c@seZdZdZdS)Ú    DataErrorz;Exception for errors reporting problems with processed dataNr-r"r"r"r#r4jsr4c@seZdZdZdS)ÚNotSupportedErrorzBException for errors when an unsupported database feature was usedNr-r"r"r"r#r5nsr5c@seZdZdZdS)Ú    PoolErrorz3Exception for errors relating to connection poolingNr-r"r"r"r#r6rsr6Ú_CUSTOM_ERROR_EXCEPTIONSN)ÚerrorÚ    exceptionrc CsÂt|tƒr|siatS|s"|s"tSt|ttfƒs8tdƒ‚t|tƒrJ||i}| ¡D]j\}}t|tƒsltdƒ‚z|dks€t|tƒs„t‚Wn,tk
r²}ztdƒ|‚W5d}~XYnX|t|<qRtS)ayDefine custom exceptions for MySQL server errors
 
    This function defines custom exceptions for MySQL server errors and
    returns the current set customizations.
 
    If error is a MySQL Server error number, then you have to pass also the
    exception class.
 
    The error argument can also be a dictionary in which case the key is
    the server error number, and value the exception to be raised.
 
    If none of the arguments are given, then custom_error_exception() will
    simply return the current set customizations.
 
    To reset the customizations, simply supply an empty dictionary.
 
    Examples:
        import mysql.connector
        from mysql.connector import errorcode
 
        # Server error 1028 should raise a DatabaseError
        mysql.connector.custom_error_exception(
            1028, mysql.connector.DatabaseError)
 
        # Or using a dictionary:
        mysql.connector.custom_error_exception({
            1028: mysql.connector.DatabaseError,
            1029: mysql.connector.OperationalError,
            })
 
        # Reset
        mysql.connector.custom_error_exception({})
 
    Returns a dictionary.
    z<The error argument should be either an integer or dictionaryz!Error number should be an integerNz)Exception should be subclass of Exception)    Ú
isinstanceÚdictr7r*Ú
ValueErrorÚitemsÚ
issubclassÚ    Exceptionr)r8r9rÚ
_exceptionrr"r"r#Úcustom_error_exception•s&)
 
 
rAF)rrrÚwarningrcCs¶zt||||dWStk
r(YnXzt||||dWStk
rRYnX|sr|rft||ƒSt||dSzt|dd…|||dWStk
r°t|||dYSXdS)a>Get the exception matching the MySQL error
 
    This function will return an exception based on the SQLState. The given
    message will be passed on in the returned exception.
 
    The exception returned can be customized using the
    mysql.connector.custom_error_exception() function.
 
    Returns an Exception
    )rrr)rrréN)r7ÚKeyErrorÚ_ERROR_EXCEPTIONSr,r/Ú_SQLSTATE_CLASS_EXCEPTION)rrrrBr"r"r#Úget_mysql_exceptionØs(
 ÿrG)Úpacketrc
Csd}}z|ddkrtdƒ‚Wn6tk
rV}ztd|›dƒWY¢Sd}~XYnXd}zt|dd…}t|dƒ\}}|d    d
kr¤t|ttfƒrž| d ¡}qÎ|}n*t|d d…dƒ\}}| d ¡}| d ¡}Wn<tt    fk
r }ztd|›dƒWY¢Sd}~XYnXt
|||ƒS) zªReturns an exception object based on the MySQL error
 
    Returns an exception object based on the MySQL error in the given
    packet.
 
    Returns an Error-Object.
    NééÿzPacket is not an error packetz"Failed getting Error information (rérCré#Úutf8r) r<Ú
IndexErrorr.r r:ÚbytesÚ    bytearrayÚdecoder Ú UnicodeErrorrG)rHrÚerrmsgrrr"r"r#Ú get_exceptions(  &   
&rT)Ú02Z07Z08Z0AZ21Z22Z23Z24Z25Z26Z27Z28Z2AZ2BZ2CZ2DZ2EZ33Z34Z35Z37Z3CZ3DZ3FZ40Z42Z44ZHZZXAZ0KZHYrF)iÛiºiÒiÝiii iêrE)NN)NNF)(r(ÚtypingrrrrrrZlocalesr    Útypesr
Úutilsr r r?r r,r.r/r0r1r2r3r4r5r6ZErrorClassTypesZ
ErrorTypesr7r*Ú__annotations__rAr)ÚboolrGrOrTrFrEr"r"r"r#Ú<module>sÌ   )÷ÿ öÿþý Eüû *$á#ø