因为python3现在还不能直接连接数据库,所有如果想连接,就只能通过以下方法:

在APP中的,__init__.py中,添加以下代码就可以:

import pymysql

pymysql.install_as_MySQLdb()

当然前提是,那就的在setting.py中连接数据库添加所连接的mysql数据库的详细信息,如下:

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME':'PerfectCRM',
'USER': '***',
'PASSWORD': '***',
'HOST': '',
'PORT': '',
}
}

相关文章:

  • 2023-04-03
  • 2021-06-08
  • 2021-05-12
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2021-08-11
猜你喜欢
  • 2021-05-20
  • 2021-12-08
  • 2021-11-21
  • 2021-12-20
  • 2022-12-23
  • 2022-01-23
  • 2021-12-23
相关资源
相似解决方案