After you configure virtualenv and virtualenvwrapper, use Pycharm to create a new project. Then the problem to be faced with, has been using SQLite as a development database to learn, according to the principles of the previous tutorial, as if the development environment to the production environment as much as possible, so now want to try to use a more likely to deploy in the production environment MySQL database development.
I thought it was a very easy thing to do, but I didn't expect to get into some trouble.
According to a pass Baidu, the search out of the plan is probably:
MySQLdb
MySQL installation time with the connector
Pymysql
MySQLdb
The first Django official recommendation was the database link library that Django officially recommended, and it was my first attempt. However, the installation of the time can not find suitable for 64-bit, python2.78 installation files! Through an article introduced modify reluctantly installed on the support of 2.7 version, the results are always used when Unicode error, MySQL database also according to the tutorial set into the UTF8 code, had to forget
2, connector with the
It's an official version, but according to the official installation method, there's always no Mysql.connector.django this module .... Don't understand why. Look for the successful installation of the students and then met the Chinese Unicode error .... Residual reading
3,pymysql
This is a blog about Python3 trial Django-mysql solution. At first because the unofficial did not make, it is an accident simple success ...
Add in Project's inti.py:
Copy 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 ', #数据库主机, defaults to localhost
' PORT ': ' 3306 ', #数据库端口, MySQL defaults to 3306
' OPTIONS ': {
' Autocommit ': True,
},
}
}