How to use MySql pythonDjango in combination with Python3.4 in Django1.6
Alas, a new wave recently emerged, using Python3.4 and Django1.6. databases are still common MySql for Internet enterprises.
Sadly, MySQLdb connected to MySql in the Python2.7 era does not support Python3.4 yet. Fortunately, I am struggling to ask G brother to find a replacement product and the effect is good. this replacement product is pymysql.
Download this item and install it. it is the same as other python third package.
The DATABASES settings in Django1.6 are the same as those in MySQLdb, as shown below:
1 DATABASES = {2 'default': {3 'engine': 'Django. db. backends. mysql ', # Database Engine 4 'name': 'test', # Database NAME 5 'user': 'root', # Username 6 'password': 'root ', # Password: 7'host': '', # Database HOST. the default value is localhost 8 'port':'', # Database PORT. MySQL defaults to 3306 'options ': {10 'autocommit ': True, 11}, 12} 13}
The most critical point is to add the following code in the _ init _. py file of the site:
1 import pymysql2 pymysql. install_as_MySQLdb ()
After completing the preceding steps, you can access mysql in django.