首页 > 学院 > 开发设计 > 正文

django使用配置文件进行数据库连接

2019-11-06 07:51:04
字体:
来源:转载
供稿:网友

settings.py文件里面DATABASES 这么配置

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.MySQL', 'OPTIONS': { 'read_default_file': os.path.dirname(os.path.abspath(__file__))+'/my.cnf', }, }}

my.cnf文件

[client]host = 127.0.0.1port = 3306database = testuser = testpassWord = testdefault-character-set = utf8
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表