django Mysql初始化命令
mysql可以指定每一个表的存储引擎,甚至也可以支持每个字段采用不同的字符编码。为了减少乱码方面的麻烦,需要在配置文件(settings.py)中指定默认的编码格式。
类似的配置如下:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'venus', # Or path to database file if using sqlite3.
'USER': 'dev', # Not used with sqlite3.
'PASSWORD': 'dev', # Not used with sqlite3.
'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
'OPTIONS': { 'init_command': 'SET storage_engine=INNODB,character_set_connection=utf8,collation_connection=utf8_unicode_ci'}
}
}

浙公网安备 33010602011771号