U ac@spddlZddlmZddlmZddlmZGdddeZGdd d eejZ Gd d d eej Z Gd d d ej Z GdddejejZGdddeejZGdddeejZGddde ZGddde ejZGddde ejZGddde ejZGddde ejZGddde ZGd d!d!e ZGd"d#d#e ejZGd$d%d%ejZGd&d'd'ejZGd(d)d)ejZGd*d+d+ejZGd,d-d-ejZGd.d/d/e ej Z Gd0d1d1e Z!Gd2d3d3e Z"Gd4d5d5e Z#Gd6d7d7e ej$Z$Gd8d9d9e ej%Z%Gd:d;d;e ej&Z&Gdd?d?ej(Z)Gd@dAdAej(Z*GdBdCdCej(Z+dS)DN)exc)types)utilcs*eZdZdZdfdd ZddZZS) _NumericTypezvBase for MySQL numeric types. This is the base both for NUMERIC as well as INTEGER, hence it's a mixin. Fc s"||_||_tt|jf|dSN)unsignedzerofillsuperr__init__)selfrr kw __class__`C:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-nyjtotrf\sqlalchemy\dialects\mysql\types.pyr sz_NumericType.__init__cCstj|ttjgdSN)Z to_inspect)r generic_reprrsqltypesZNumericr rrr__repr__sz_NumericType.__repr__)FF__name__ __module__ __qualname____doc__r r __classcell__rrrrrsrcs&eZdZdfdd ZddZZS) _FloatTypeNTc s^t|ttfr8|dkr|dk s.|dk r8|dkr8tdtt|jf||d|||_dS)NzBYou must specify both precision and scale or omit both altogether.) precision asdecimal) isinstanceREALDOUBLEr ArgumentErrorr rr scaler rr$rr rrrr #s& z_FloatType.__init__cCstj|tttjgdSr)rrrrrFloatrrrrr1s z_FloatType.__repr__)NNTrrrr rrrrrrr"srcs&eZdZdfdd ZddZZS) _IntegerTypeNc s||_tt|jf|dSr) display_widthr r(r r r)r rrrr 8sz_IntegerType.__init__cCstj|tttjgdSr)rrr(rrIntegerrrrrr<s z_IntegerType.__repr__)Nr'rrrrr(7sr(cs*eZdZdZdfdd ZddZZS) _StringTypezBase for MySQL string types.NFc sH||_|d|d|||_||_||_||_tt|j f|dS)N collationZcollate) charset setdefaultpopasciiunicodebinarynationalr r,r )r r.r-r1r3r2r4r rrrr Es z_StringType.__init__cCstj|ttjgdSr)rrr,rStringrrrrrZsz_StringType.__repr__)NNFFFFrrrrrr,Bsr,c@seZdZddZdS) _MatchTypecKstj|tj|dSr)rr&r MatchType)r r rrrr as z_MatchType.__init__N)rrrr rrrrr6`sr6cs&eZdZdZdZdfdd ZZS)NUMERICzMySQL NUMERIC type.NTc s"tt|jf|||d|dS)a#Construct a NUMERIC. :param precision: Total digits in this number. If scale and precision are both None, values are stored to limits allowed by the server. :param scale: The number of digits after the decimal point. :param unsigned: a boolean, optional. :param zerofill: Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric. rr$rN)r r8r r%rrrr ls zNUMERIC.__init__)NNTrrrr__visit_name__r rrrrrr8gsr8cs&eZdZdZdZdfdd ZZS)DECIMALzMySQL DECIMAL type.NTc s"tt|jf|||d|dS)a#Construct a DECIMAL. :param precision: Total digits in this number. If scale and precision are both None, values are stored to limits allowed by the server. :param scale: The number of digits after the decimal point. :param unsigned: a boolean, optional. :param zerofill: Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric. r9N)r r<r r%rrrr s zDECIMAL.__init__)NNTr:rrrrr<sr<cs&eZdZdZdZdfdd ZZS)r"zMySQL DOUBLE type.NTc s"tt|jf|||d|dS)aConstruct a DOUBLE. .. note:: The :class:`.DOUBLE` type by default converts from float to Decimal, using a truncation that defaults to 10 digits. Specify either ``scale=n`` or ``decimal_return_scale=n`` in order to change this scale, or ``asdecimal=False`` to return values directly as Python floating points. :param precision: Total digits in this number. If scale and precision are both None, values are stored to limits allowed by the server. :param scale: The number of digits after the decimal point. :param unsigned: a boolean, optional. :param zerofill: Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric. r9N)r r"r r%rrrr s zDOUBLE.__init__)NNTr:rrrrr"sr"cs&eZdZdZdZdfdd ZZS)r!zMySQL REAL type.NTc s"tt|jf|||d|dS)aConstruct a REAL. .. note:: The :class:`.REAL` type by default converts from float to Decimal, using a truncation that defaults to 10 digits. Specify either ``scale=n`` or ``decimal_return_scale=n`` in order to change this scale, or ``asdecimal=False`` to return values directly as Python floating points. :param precision: Total digits in this number. If scale and precision are both None, values are stored to limits allowed by the server. :param scale: The number of digits after the decimal point. :param unsigned: a boolean, optional. :param zerofill: Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric. r9N)r r!r r%rrrr s z REAL.__init__)NNTr:rrrrr!sr!cs.eZdZdZdZdfdd ZddZZS) FLOATzMySQL FLOAT type.NFc s"tt|jf|||d|dS)a!Construct a FLOAT. :param precision: Total digits in this number. If scale and precision are both None, values are stored to limits allowed by the server. :param scale: The number of digits after the decimal point. :param unsigned: a boolean, optional. :param zerofill: Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric. r9N)r r=r r%rrrr s zFLOAT.__init__cCsdSrr)r dialectrrrbind_processorszFLOAT.bind_processor)NNF)rrrrr;r r?rrrrrr=sr=cs&eZdZdZdZdfdd ZZS)INTEGERzMySQL INTEGER type.Nc stt|jfd|i|dS)aConstruct an INTEGER. :param display_width: Optional, maximum display width for this number. :param unsigned: a boolean, optional. :param zerofill: Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric. r)N)r r@r r*rrrr s zINTEGER.__init__)Nr:rrrrr@sr@cs&eZdZdZdZdfdd ZZS)BIGINTzMySQL BIGINTEGER type.Nc stt|jfd|i|dS)aConstruct a BIGINTEGER. :param display_width: Optional, maximum display width for this number. :param unsigned: a boolean, optional. :param zerofill: Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric. r)N)r rAr r*rrrr s zBIGINT.__init__)Nr:rrrrrAsrAcs&eZdZdZdZdfdd ZZS) MEDIUMINTzMySQL MEDIUMINTEGER type.Nc stt|jfd|i|dS)aConstruct a MEDIUMINTEGER :param display_width: Optional, maximum display width for this number. :param unsigned: a boolean, optional. :param zerofill: Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric. r)N)r rBr r*rrrr +s zMEDIUMINT.__init__)Nr:rrrrrB&srBcs&eZdZdZdZdfdd ZZS)TINYINTzMySQL TINYINT type.Nc stt|jfd|i|dS)aConstruct a TINYINT. :param display_width: Optional, maximum display width for this number. :param unsigned: a boolean, optional. :param zerofill: Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric. r)N)r rCr r*rrrr @s zTINYINT.__init__)Nr:rrrrrC;srCcs&eZdZdZdZdfdd ZZS)SMALLINTzMySQL SMALLINTEGER type.Nc stt|jfd|i|dS)aConstruct a SMALLINTEGER. :param display_width: Optional, maximum display width for this number. :param unsigned: a boolean, optional. :param zerofill: Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric. r)N)r rDr r*rrrr Us zSMALLINT.__init__)Nr:rrrrrDPsrDc@s&eZdZdZdZdddZddZdS)BITzMySQL BIT type. This type is for MySQL 5.0.3 or greater for MyISAM, and 5.0.5 or greater for MyISAM, MEMORY, InnoDB and BDB. For older versions, use a MSTinyInteger() type. NcCs ||_dS)zLConstruct a BIT. :param length: Optional, number of bits. Nlength)r rGrrrr psz BIT.__init__cCs dd}|S)zConvert a MySQL's 64 bit, variable length binary string to a long. TODO: this is MySQL-db, pyodbc specific. OurSQL and mysqlconnector already do this, so this logic should be moved to those dialects. cSs<|dk r8d}|D]"}t|ts&t|}|d>|B}q|S|S)Nr)r intord)valuevirrrprocesss z%BIT.result_processor..processrr r>ZcoltyperNrrrresult_processorxs zBIT.result_processor)N)rrrrr;r rPrrrrrEes rEcs.eZdZdZdZdfdd ZddZZS) TIMEzMySQL TIME type.FNcstt|j|d||_dS)aConstruct a MySQL TIME type. :param timezone: not used by the MySQL dialect. :param fsp: fractional seconds precision value. MySQL 5.6 supports storage of fractional seconds; this parameter will be used when emitting DDL for the TIME type. .. note:: DBAPI driver support for fractional seconds may be limited; current support includes MySQL Connector/Python. timezoneN)r rQr fspr rSrTrrrr sz TIME.__init__cstjfdd}|S)NcsD|dk r<|j}|j}|d}|d|d||d|dSdSdS)N<) microsecond) microsecondsseconds)rKrXrYminutestimerrrNs z&TIME.result_processor..process)datetimer\rOrr[rrPs zTIME.result_processor)FN)rrrrr;r rPrrrrrrQsrQcs&eZdZdZdZdfdd ZZS) TIMESTAMPzMySQL TIMESTAMP type.FNcstt|j|d||_dS)aConstruct a MySQL TIMESTAMP type. :param timezone: not used by the MySQL dialect. :param fsp: fractional seconds precision value. MySQL 5.6.4 supports storage of fractional seconds; this parameter will be used when emitting DDL for the TIMESTAMP type. .. note:: DBAPI driver support for fractional seconds may be limited; current support includes MySQL Connector/Python. rRN)r r^r rTrUrrrr szTIMESTAMP.__init__)FNr:rrrrr^sr^cs&eZdZdZdZdfdd ZZS)DATETIMEzMySQL DATETIME type.FNcstt|j|d||_dS)aConstruct a MySQL DATETIME type. :param timezone: not used by the MySQL dialect. :param fsp: fractional seconds precision value. MySQL 5.6.4 supports storage of fractional seconds; this parameter will be used when emitting DDL for the DATETIME type. .. note:: DBAPI driver support for fractional seconds may be limited; current support includes MySQL Connector/Python. rRN)r r_r rTrUrrrr szDATETIME.__init__)FNr:rrrrr_sr_c@seZdZdZdZdddZdS)YEARzszMEDIUMTEXT.__init__r:rrrrre9srecs$eZdZdZdZfddZZS)LONGTEXTz4MySQL LONGTEXT type, for text up to 2^32 characters.c stt|jf|dS)aConstruct a LONGTEXT. :param charset: Optional, a column-level character set for this string value. Takes precedence to 'ascii' or 'unicode' short-hand. :param collation: Optional, a column-level collation for this string value. Takes precedence to 'binary' short-hand. :param ascii: Defaults to False: short-hand for the ``latin1`` character set, generates ASCII in schema. :param unicode: Defaults to False: short-hand for the ``ucs2`` character set, generates UNICODE in schema. :param national: Optional. If true, use the server's configured national character set. :param binary: Defaults to False: short-hand, pick the binary collation type that matches the column's character set. Generates BINARY in schema. This does not affect the type of data stored, only the collation of character data. N)r rfr rcrrrr ^szLONGTEXT.__init__r:rrrrrfYsrfcs&eZdZdZdZdfdd ZZS)VARCHARz7MySQL VARCHAR type, for variable-length character data.Nc stt|jfd|i|dS)aConstruct a VARCHAR. :param charset: Optional, a column-level character set for this string value. Takes precedence to 'ascii' or 'unicode' short-hand. :param collation: Optional, a column-level collation for this string value. Takes precedence to 'binary' short-hand. :param ascii: Defaults to False: short-hand for the ``latin1`` character set, generates ASCII in schema. :param unicode: Defaults to False: short-hand for the ``ucs2`` character set, generates UNICODE in schema. :param national: Optional. If true, use the server's configured national character set. :param binary: Defaults to False: short-hand, pick the binary collation type that matches the column's character set. Generates BINARY in schema. This does not affect the type of data stored, only the collation of character data. rGN)r rgr r rGrdrrrr ~szVARCHAR.__init__)Nr:rrrrrgysrgcs2eZdZdZdZdfdd ZeddZZS)CHARz1MySQL CHAR type, for fixed-length character data.Nc stt|jfd|i|dS)aConstruct a CHAR. :param length: Maximum data length, in characters. :param binary: Optional, use the default binary collation for the national character set. This does not affect the type of data stored, use a BINARY type for binary data. :param collation: Optional, request a particular collation. Must be compatible with the national character set. rGN)r rir rhrrrr s z CHAR.__init__c CsVt|}t|tjr|St|trFt|j|j|j|j|j |j ddSt|jdSdS)NF)rGr.r-r1r3r2r4rF) rZ to_instancer rir,rGr.r-r1r3r2)r type_rrr_adapt_string_for_casts    zCHAR._adapt_string_for_cast)N) rrrrr;r classmethodrkrrrrrris rics&eZdZdZdZdfdd ZZS)NVARCHARzxMySQL NVARCHAR type. For variable-length character data in the server's configured national character set. Nc s&d|d<tt|jfd|i|dS)aConstruct an NVARCHAR. :param length: Maximum data length, in characters. :param binary: Optional, use the default binary collation for the national character set. This does not affect the type of data stored, use a BINARY type for binary data. :param collation: Optional, request a particular collation. Must be compatible with the national character set. Tr4rGN)r rmr rhrrrr s zNVARCHAR.__init__)Nr:rrrrrmsrmcs&eZdZdZdZdfdd ZZS)NCHARzrMySQL NCHAR type. For fixed-length character data in the server's configured national character set. Nc s&d|d<tt|jfd|i|dS)aConstruct an NCHAR. :param length: Maximum data length, in characters. :param binary: Optional, use the default binary collation for the national character set. This does not affect the type of data stored, use a BINARY type for binary data. :param collation: Optional, request a particular collation. Must be compatible with the national character set. Tr4rGN)r rnr rhrrrr s zNCHAR.__init__)Nr:rrrrrnsrnc@seZdZdZdZdS)TINYBLOBz5MySQL TINYBLOB type, for binary data up to 2^8 bytes.Nrrrrr;rrrrrosroc@seZdZdZdZdS) MEDIUMBLOBz8MySQL MEDIUMBLOB type, for binary data up to 2^24 bytes.Nrprrrrrqsrqc@seZdZdZdZdS)LONGBLOBz6MySQL LONGBLOB type, for binary data up to 2^32 bytes.Nrprrrrrrsrr),r]rrrrobjectrr&rr+r(r5r,r7r6r8r<r"r!r=r@rArBrCrDZ TypeEnginerErQr^r_r`rarbrerfrgrirmrnZ_BinaryrorqrrrrrrsD    ""(- $    )