PDF(美国高级主任)- 5.2 mb
PDF (A4)- 5.2 mb
HTML下载(TGZ)- 2.7 mb
HTML下载(Zip)- 2.7 mb
这个类提供了所有支持的MySQL字段或数据类型。在处理原始数据或定义自己的转换器时,它们很有用。字段类型与每列描述中的每个游标一起存储。
下面的示例演示如何为结果集中的每一列打印数据类型的名称。
从__future__导入print_function导入mysql。mysql连接器。connector import FieldType cnx = mysql.connector。Connect (user='scott', database='test') cursor = cnx.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{}有类型{}"。format(colname, FieldType.get_info(coltype))) cursor.close()
的FieldType
类不能实例化。