After you have configured Virtualenv and Virtualenvwrapper, use Pycharm to create a new project. After the problem is coming, has been using SQLite as a development database to learn, according to the principles of the tutorial, it seems that the development environment and production environment as much as possible, so now want to try to use more likely to deploy in the production environment of the MySQL database for development.
I think it is a very easy thing, did not expect to encounter some trouble
According to a pass Baidu, the search out of the plan is probably:
MySQLdb
MySQL installation comes with the connector
Pymysql
MySQLdb
The first Django official recommendation is the database link library that Django has officially recommended, and it's the first one I tried. But the installation of the time can not find suitable for 64-bit, python2.78 installation files! Through an article to introduce changes reluctantly installed on the support 2.7 version, the result is always Unicode error when using, MySQL database also according to the tutorial is set to UTF8 code, had to forget
2, bring your own connector
It is also a seemingly official version, but according to the official installation method is always prompted not to mysql.connector.django this module .... Don't understand why. Find out more carefully find the successful installation of the classmate and then encountered the Chinese Unicode error .... Residual thoughts
3,pymysql
This is a blog on the Python3 trial Django-mysql solution. At first because the unofficial did not make, but unexpectedly simple success ...
In Project inti.py, add:
Copy the Code code as follows:
Import Pymysql
Pymysql.install_as_mysqldb ()
Settings
DATABASES = {
' Default ': {
' ENGINE ': ' Django.db.backends.mysql ', #数据库引擎
' NAME ': ' Django ', #数据库名
' User ': ' User ', #用户名
' PASSWORD ': ' password! ', #密码
' HOST ': ' localhost ', #数据库主机, localhost by default
' PORT ': ' 3306 ', #数据库端口, MySQL defaults to 3306
' OPTIONS ': {
' Autocommit ': True,
},
}
}