1. Setting up a connection database in setting.py
DATABASES = {
' Default ': {
' ENGINE ': ' Django.db.backends.mysql ',
' NAME ': ' djangotest ',
' USER ': ' Root ',
' PASSWORD ': ' Root ',
' HOST ': ' 127.0.0.1 ',
' PORT ': ' 3306 '
}
}
- When using migrate to generate the data table will be prompted not to connect to the MYSQLDB driver, then need to install the driver
- Pip install Mysql-python, installed in the Windows environment, many will appear error:microsoft Visual C + + 9.0 is required error.
The general explanation on the web is that reinstalling MySQL and installing MySQL is the option to install C + + compilers ...
I have not tried, but it certainly does not work ah, I just want to install a python can be remotely connected to the MySQL package, tube local MySQL what? Some explanations are really fraught.
But in the error hints also thanks to the lack of C + + environment, and later found on the Internet method:
Here's how:
1. In http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python download the corresponding package version, if it is Win7 64 bit 2.7 version of Python, download
Mysql_python-1.2.5-cp27-none-win_amd64.whl
2. Enter the download directory in the virtual environment, using PIP installation, such as:
3.django connect MySQL database and install MYSQLDB driver error Resolution