美文网首页
[ django2 ] Python 3.6.6 版本连接MyS

[ django2 ] Python 3.6.6 版本连接MyS

作者: w也不知道 | 来源:发表于2019-05-09 14:36 被阅读0次
  1. 修改 settings.py 文件
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'hello',
        'USER':'root',
        'PASSWORD':'Bo55man69',
        'HOST':'127.0.0.1',
        'PORT':'3306',
        'ATOMIC_REQUESTS': True,  # 事务处理
    }
}
  1. 使用 pip 安装 PyMySQL 扩展
pip install PyMySQL
  1. 修改和 settings.py 处于同一级的 __init__.py 文件,添加以下内容
import pymysql
pymysql.install_as_MySQLdb()
migrate 结果

相关文章

网友评论

      本文标题:[ django2 ] Python 3.6.6 版本连接MyS

      本文链接:https://www.haomeiwen.com/subject/utecwqtx.html