You need to install to mysqlclient to connect to
mysql (wampserver).
For install mysqlclient you need to Visual C++ 2015 Build Tools. Use below link
to download visualstudio tool. http://go.microsoft.com/fwlink/?LinkId=691126&fixForIE=.exe.
Now you need to set your visual studio path
in path variable by using below command in commandline.
“setx path "C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC"”
Now you need to install mysqlclient by using
below command
“pip install mysqlclient”
If you found error like “MySQLdb/_mysql.c(29):
fatal error C1083: Cannot open include file: 'mysql.h': No such file or
directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio
14.0\\VC\\BIN\\cl.exe' failed with exit status 2”
so you need to download .whl file for direct
install, You can use below link to download as per your system compatibility.
“mysqlclient-1.4.2-cp37-cp37m-win32.whl” file work for me.
“pip install mysqlclient-1.4.2-cp37-cp37m-win32.whl”
Mysqlclient
is install now!!
You
need to change setting.py according to mysql
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'learnpython',
'USER': 'nilesh',
'PASSWORD': 'Radhe@12',
'HOST': 'localhost',
'PORT': 3306
}
}
Enjoy
now Django is connect with mysql!!