Django 模型与 Mysql 数据类型对应

Django 1.11.9
文件路径:site-packages\django\db\backends\mysql\base.py–class DatabaseWrapper

_data_types = {
‘AutoField’: ‘integer AUTO_INCREMENT’,
‘BigAutoField’: ‘bigint AUTO_INCREMENT’,
‘BinaryField’: ‘longblob’,
‘BooleanField’: ‘bool’,
‘CharField’: ‘varchar(%(max_length)s)’,
‘CommaSeparatedIntegerField’: ‘varchar(%(max_length)s)’,
‘DateField’: ‘date’,
‘DateTimeField’: ‘datetime’,
‘DecimalField’: ‘numeric(%(max_digits)s, %(decimal_places)s)’,
‘DurationField’: ‘bigint’,
‘FileField’: ‘varchar(%(max_length)s)’,
‘FilePathField’: ‘varchar(%(max_length)s)’,
‘FloatField’: ‘double precision’,
‘IntegerField’: ‘integer’,
‘BigIntegerField’: ‘bigint’,
‘IPAddressField’: ‘char(15)’,
‘GenericIPAddressField’: ‘char(39)’,
‘NullBooleanField’: ‘bool’,
‘OneToOneField’: ‘integer’,
‘PositiveIntegerField’: ‘integer UNSIGNED’,
‘PositiveSmallIntegerField’: ‘smallint UNSIGNED’,
‘SlugField’: ‘varchar(%(max_length)s)’,
‘SmallIntegerField’: ‘smallint’,
‘TextField’: ‘longtext’,
‘TimeField’: ‘time’,
‘UUIDField’: ‘char(32)’,

 

转载于:https://www.cnblogs.com/TianyuSu/p/9382801.html

你可能感兴趣的:(数据库,python)