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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
U
¸ý°dÇaã@srddlZddlmZddlmZddlmZGdd„dƒZGdd    „d    eejƒZGd
d „d eej    ƒZ
Gd d „d ej ƒZ Gdd„dejej ƒZGdd„deejƒZGdd„deejƒZGdd„deejƒZGdd„deejƒZGdd„deejƒZGdd„de
ejƒZGdd„de
ejƒZGdd„de
ƒZGd d!„d!e
ƒZGd"d#„d#e
ejƒZGd$d%„d%ejƒZGd&d'„d'ejƒZGd(d)„d)ejƒZGd*d+„d+ejƒZGd,d-„d-ejƒZGd.d/„d/e ejƒZGd0d1„d1e ƒZ Gd2d3„d3e ƒZ!Gd4d5„d5e ƒZ"Gd6d7„d7e ej#ƒZ#Gd8d9„d9e ej$ƒZ$Gd:d;„d;e ej%ƒZ%Gd<d=„d=e ej&ƒZ&Gd>d?„d?ej'ƒZ(Gd@dA„dAej'ƒZ)GdBdC„dCej'ƒZ*dS)DéNé)Úexc)Úutil)Úsqltypescs*eZdZdZd‡fdd„    Zdd„Z‡ZS)Ú _NumericTypezvBase for MySQL numeric types.
 
    This is the base both for NUMERIC as well as INTEGER, hence
    it's a mixin.
 
    Fc s||_||_tƒjf|ŽdS©N)ÚunsignedÚzerofillÚsuperÚ__init__)Úselfrr    Úkw©Ú    __class__©úVd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/dialects/mysql/types.pyr sz_NumericType.__init__cCstj|ttjgdS©N)Z
to_inspect)rÚ generic_reprrrZNumeric©r rrrÚ__repr__sÿz_NumericType.__repr__)FF©Ú__name__Ú
__module__Ú __qualname__Ú__doc__r rÚ __classcell__rrrrrsrcs&eZdZd‡fdd„    Zdd„Z‡ZS)Ú
_FloatTypeNTc sZt|ttfƒr8|dkr|dk    s.|dk    r8|dkr8t d¡‚tƒjf||dœ|—Ž||_dS)NzBYou must specify both precision and scale or omit both altogether.)Ú    precisionÚ    asdecimal)Ú
isinstanceÚREALÚDOUBLErÚ ArgumentErrorr
r Úscale©r rr#rr rrrr %sÿÿþþÿz_FloatType.__init__cCstj|tttjgdSr)rrrrrÚFloatrrrrr1s
ÿz_FloatType.__repr__)NNT©rrrr rrrrrrr$s rcs&eZdZd‡fdd„    Zdd„Z‡ZS)Ú _IntegerTypeNc s||_tƒjf|ŽdSr)Ú display_widthr
r ©r r(r rrrr 8sz_IntegerType.__init__cCstj|tttjgdSr)rrr'rrÚIntegerrrrrr<s
ÿz_IntegerType.__repr__)Nr&rrrrr'7sr'cs*eZdZdZd‡fdd„    Zdd„Z‡ZS)    Ú _StringTypezBase for MySQL string types.NFc sD||_| d| d|¡¡||_||_||_||_tƒjf|ŽdS)NÚ    collationZcollate)    ÚcharsetÚ
setdefaultÚpopÚasciiÚunicodeÚbinaryÚnationalr
r )r r-r,r0r2r1r3r rrrr Es
z_StringType.__init__cCstj|ttjgdSr)rrr+rÚStringrrrrrZsÿz_StringType.__repr__)NNFFFFrrrrrr+Bsùr+c@seZdZdd„ZdS)Ú
_MatchTypecKstj |¡tj |¡dSr)rr%r Ú    MatchType)r r rrrr as z_MatchType.__init__N)rrrr rrrrr5`sr5cs&eZdZdZdZd‡fdd„    Z‡ZS)ÚNUMERICzMySQL NUMERIC type.NTc stƒ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
r r$rrrr lsÿÿzNUMERIC.__init__)NNT©rrrrÚ__visit_name__r rrrrrr7gsr7cs&eZdZdZdZd‡fdd„    Z‡ZS)ÚDECIMALzMySQL DECIMAL type.NTc stƒ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.
 
        r8Nr9r$rrrr †sÿÿzDECIMAL.__init__)NNTr:rrrrr<sr<cs&eZdZdZdZd‡fdd„    Z‡ZS)r!zMySQL DOUBLE type.NTc stƒjf|||dœ|—ŽdS)aŠConstruct 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.
 
        r8Nr9r$rrrr  sÿÿzDOUBLE.__init__)NNTr:rrrrr!›sr!cs&eZdZdZdZd‡fdd„    Z‡ZS)r zMySQL REAL type.NTc stƒjf|||dœ|—ŽdS)a†Construct 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.
 
        r8Nr9r$rrrr Âsÿÿz REAL.__init__)NNTr:rrrrr ½sr cs.eZdZdZdZd‡fdd„    Zdd„Z‡ZS)    ÚFLOATzMySQL FLOAT type.NFc stƒ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.
 
        r8Nr9r$rrrr äsÿÿzFLOAT.__init__cCsdSrr)r ÚdialectrrrÚbind_processorøszFLOAT.bind_processor)NNF)rrrrr;r r?rrrrrr=ßsr=cs&eZdZdZdZd‡fdd„    Z‡ZS)ÚINTEGERzMySQL INTEGER type.Nc stƒjfd|i|—ŽdS)a“Construct 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(Nr9r)rrrr s zINTEGER.__init__)Nr:rrrrr@üsr@cs&eZdZdZdZd‡fdd„    Z‡ZS)ÚBIGINTzMySQL BIGINTEGER type.Nc stƒjfd|i|—ŽdS)a•Construct 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(Nr9r)rrrr s zBIGINT.__init__)Nr:rrrrrAsrAcs&eZdZdZdZd‡fdd„    Z‡ZS)Ú    MEDIUMINTzMySQL MEDIUMINTEGER type.Nc stƒjfd|i|—ŽdS)a—Construct 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(Nr9r)rrrr +s zMEDIUMINT.__init__)Nr:rrrrrB&srBcs&eZdZdZdZd‡fdd„    Z‡ZS)ÚTINYINTzMySQL TINYINT type.Nc stƒjfd|i|—ŽdS)a’Construct 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(Nr9r)rrrr @s zTINYINT.__init__)Nr:rrrrrC;srCcs&eZdZdZdZd‡fdd„    Z‡ZS)ÚSMALLINTzMySQL SMALLINTEGER type.Nc stƒjfd|i|—ŽdS)a—Construct 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(Nr9r)rrrr Us zSMALLINT.__init__)Nr:rrrrrDPsrDc@s&eZdZdZdZddd„Zdd„ZdS)ÚBITzÀMySQL 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.
 
        N©Úlength)r rGrrrr psz BIT.__init__cCs dd„}|S)zãConvert 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|tƒs&t|ƒ}|d>|B}q|S|S)Nré)rÚintÚord)ÚvalueÚvÚirrrÚprocess€s
z%BIT.result_processor.<locals>.processr©r r>ZcoltyperNrrrÚresult_processorxs
zBIT.result_processor)N)rrrrr;r rPrrrrrEes
rEcs.eZdZdZdZd‡fdd„    Zdd„Z‡ZS)    ÚTIMEzMySQL TIME type.FNcstƒj|d||_dS)aËConstruct 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
r Úfsp©r rSrUrrrr ’sz TIME.__init__cstj‰‡fdd„}|S)NcsD|dk    r<|j}|j}|d}ˆ|d|d||d|dSdSdS)Né<)Ú microsecond)Ú microsecondsÚseconds)rKrYrZÚminutes©ÚtimerrrN¨s
üz&TIME.result_processor.<locals>.process)Údatetimer]rOrr\rrP¥s zTIME.result_processor)FN)rrrrr;r rPrrrrrrQsrQcs&eZdZdZdZd‡fdd„    Z‡ZS)Ú    TIMESTAMPzMySQL TIMESTAMP type.FNcstƒj|d||_dS)a×Construct 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.
 
        rRNrTrVrrrr ¿szTIMESTAMP.__init__)FNr:rrrrr_ºsr_cs&eZdZdZdZd‡fdd„    Z‡ZS)ÚDATETIMEzMySQL DATETIME type.FNcstƒj|d||_dS)aÕConstruct 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.
 
        rRNrTrVrrrr ØszDATETIME.__init__)FNr:rrrrr`Ósr`c@seZdZdZdZddd„ZdS)ÚYEARz<MySQL YEAR type, for single byte storage of years 1901-2155.NcCs
||_dSr)r()r r(rrrr ñsz YEAR.__init__)N)rrrrr;r rrrrraìsracs&eZdZdZdZd‡fdd„    Z‡ZS)ÚTEXTz0MySQL TEXT type, for text up to 2^16 characters.Nc stƒjfd|i|—ŽdS)acConstruct a TEXT.
 
        :param length: Optional, if provided the server may optimize storage
          by substituting the smallest TEXT type sufficient to store
          ``length`` characters.
 
        :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.
 
        rGNr9)r rGr rrrr úsz TEXT.__init__)Nr:rrrrrbõsrbcs$eZdZdZdZ‡fdd„Z‡ZS)ÚTINYTEXTz3MySQL TINYTEXT type, for text up to 2^8 characters.c stƒjf|ŽdS)a³Construct a TINYTEXT.
 
        :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.
 
        Nr9©r Úkwargsrrrr szTINYTEXT.__init__r:rrrrrcsrccs$eZdZdZdZ‡fdd„Z‡ZS)Ú
MEDIUMTEXTz6MySQL MEDIUMTEXT type, for text up to 2^24 characters.c stƒjf|ŽdS)aµConstruct a MEDIUMTEXT.
 
        :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.
 
        Nr9rdrrrr >szMEDIUMTEXT.__init__r:rrrrrf9srfcs$eZdZdZdZ‡fdd„Z‡ZS)ÚLONGTEXTz4MySQL LONGTEXT type, for text up to 2^32 characters.c stƒjf|ŽdS)a³Construct 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.
 
        Nr9rdrrrr ^szLONGTEXT.__init__r:rrrrrgYsrgcs&eZdZdZdZd‡fdd„    Z‡ZS)ÚVARCHARz7MySQL VARCHAR type, for variable-length character data.Nc stƒjfd|i|—ŽdS)a²Construct 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.
 
        rGNr9©r rGrerrrr ~szVARCHAR.__init__)Nr:rrrrrhysrhcs2eZdZdZdZd‡fdd„    Zedd„ƒZ‡ZS)ÚCHARz1MySQL CHAR type, for fixed-length character data.Nc stƒjfd|i|—ŽdS)a¤Construct 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.
 
        rGNr9rirrrr žs z CHAR.__init__c    CsVt |¡}t|tjƒr|St|tƒrFt|j|j|j|j|j    |j
ddSt|jdSdS)NF)rGr-r,r0r2r1r3rF) rZ to_instancerrjr+rGr-r,r0r2r1)r Útype_rrrÚ_adapt_string_for_cast­s
 
ù
zCHAR._adapt_string_for_cast)N)    rrrrr;r Ú classmethodrlrrrrrrj™s
rjcs&eZdZdZdZd‡fdd„    Z‡ZS)ÚNVARCHARzxMySQL NVARCHAR type.
 
    For variable-length character data in the server's configured national
    character set.
    Nc s"d|d<tƒjfd|i|—ŽdS)a©Construct 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.
 
        Tr3rGNr9rirrrr Ës zNVARCHAR.__init__)Nr:rrrrrnÂsrncs&eZdZdZdZd‡fdd„    Z‡ZS)ÚNCHARzrMySQL NCHAR type.
 
    For fixed-length character data in the server's configured national
    character set.
    Nc s"d|d<tƒjfd|i|—ŽdS)a¦Construct 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.
 
        Tr3rGNr9rirrrr ås zNCHAR.__init__)Nr:rrrrroÜsroc@seZdZdZdZdS)ÚTINYBLOBz5MySQL TINYBLOB type, for binary data up to 2^8 bytes.N©rrrrr;rrrrrpösrpc@seZdZdZdZdS)Ú
MEDIUMBLOBz8MySQL MEDIUMBLOB type, for binary data up to 2^24 bytes.Nrqrrrrrrüsrrc@seZdZdZdZdS)ÚLONGBLOBz6MySQL LONGBLOB type, for binary data up to 2^32 bytes.Nrqrrrrrssrs)+r^ÚrrZsqlrrr%rr*r'r4r+r6r5r7r<r!r r=r@rArBrCrDZ
TypeEnginerErQr_r`rarbrcrfrgrhrjrnroZ_BinaryrprrrsrrrrÚ<module>
sD    ""(-    $    )