builtins.object ABC _Constants FieldType
class FieldType(_Constants):
MySQL Field Types. This class provides all supported MySQL field or data types. They can be useful when dealing with raw data or defining your own converters. The field type is stored with every cursor in the description for each column. The `FieldType` class shouldn't be instantiated. Examples: The following example shows how to print the name of the data type for each column in a result set. ``` from __future__ import print_function import mysql.connector from mysql.connector import FieldType cnx = mysql.connector.connect(user='scott', database='test') cursor = cnx.cursor() cursor.execute( "SELECT DATE(NOW()) AS `c1`, TIME(NOW()) AS `c2`, " "NOW() AS `c3`, 'a string' AS `c4`, 42 AS `c5`") rows = cursor.fetchall() for desc in cursor.description: colname = desc[0] coltype = desc[1] print("Column {} has type {}".format( colname, FieldType.get_info(coltype))) cursor.close() cnx.close() ```
Signature du constructeur | Description |
---|---|
__init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. [extrait de __init__.__doc__] |
Nom de l'attribut | Valeur |
---|---|
BIT | 16 |
BLOB | 252 |
DATE | 10 |
DATETIME | 12 |
DECIMAL | 0 |
desc | {'DECIMAL': (0, 'DECIMAL'), 'TINY': (1, 'TINY'), 'SHORT': (2, 'SHORT'), 'LONG': (3, 'LONG'), 'FLOAT': (4, 'FLOAT'), 'DOUBLE': (5, 'DOUBLE'), 'NULL': (6, 'NULL'), 'TIMESTAMP': (7, 'TIMESTAMP'), 'LONGLONG': (8, 'LONGLONG'), 'INT24': (9, 'INT24'), 'DATE': (10, 'DATE'), 'TIME': (11, 'TIME'), 'DATETIME': (12, 'DATETIME'), 'YEAR': (13, 'YEAR'), 'NEWDATE': (14, 'NEWDATE'), 'VARCHAR': (15, 'VARCHAR'), 'BIT': (16, 'BIT'), 'VECTOR': (242, 'VECTOR'), 'JSON': (245, 'JSON'), 'NEWDECIMAL': (246, 'NEWDECIMAL'), 'ENUM': (247, 'ENUM'), 'SET': (248, 'SET'), 'TINY_BLOB': (249, 'TINY_BLOB'), 'MEDIUM_BLOB': (250, 'MEDIUM_BLOB'), 'LONG_BLOB': (251, 'LONG_BLOB'), 'BLOB': (252, 'BLOB'), 'VAR_STRING': (253, 'VAR_STRING'), 'STRING': (254, 'STRING'), 'GEOMETRY': (255, 'GEOMETRY')} |
DOUBLE | 5 |
ENUM | 247 |
FLOAT | 4 |
GEOMETRY | 255 |
INT24 | 9 |
JSON | 245 |
LONG | 3 |
LONG_BLOB | 251 |
LONGLONG | 8 |
MEDIUM_BLOB | 250 |
NEWDATE | 14 |
NEWDECIMAL | 246 |
NULL | 6 |
prefix | FIELD_TYPE_ |
SET | 248 |
SHORT | 2 |
STRING | 254 |
TIME | 11 |
TIMESTAMP | 7 |
TINY | 1 |
TINY_BLOB | 249 |
VAR_STRING | 253 |
VARCHAR | 15 |
VECTOR | 242 |
YEAR | 13 |
Signature de la méthode | Description |
---|---|
get_binary_types() -> List[int] | Get the list of all binary types [extrait de get_binary_types.__doc__] |
get_number_types() -> List[int] | Get the list of all number types [extrait de get_number_types.__doc__] |
get_string_types() -> List[int] | Get the list of all string types [extrait de get_string_types.__doc__] |
get_timestamp_types() -> List[int] | Get the list of all timestamp types [extrait de get_timestamp_types.__doc__] |
Améliorations / Corrections
Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.
Emplacement :
Description des améliorations :