Django1.7 + python 2.78 + pycharm configure mysql database, django1.7pycharm

Source: Internet
Author: User

Django1.7 + python 2.78 + pycharm configure mysql database, django1.7pycharm

After virtualenv and virtualenvwrapper are configured, use pycharm to create a new project. The problems that we will face later come. We have been learning sqlite as a development database. According to the principles of the previous tutorials, it seems that the development environment should be as consistent as possible with the production environment, so now I want to try to use a mysql database that is more likely to be deployed in the production environment for development.

I thought it was a very easy task, but I didn't expect any trouble.

According to a channel called Baidu, the following solutions are available:

MySQLdb
Mysql connector
Pymysql

MySQLdb is the first database link library officially recommended by django. It is naturally my first attempt. However, no installation file suitable for 64-bit python2.78 was found during installation! After an article about the modification, we barely installed a version that supports version 2.7. unicode errors are always reported when the result is used, and mysql databases are set to utf8 encoding according to the tutorial.

2. built-in ctor

It is also a very official version, but according to the official installation method, it is always prompted that there is no mysql. connector. django module .... I don't understand why. After finding out that the installation was successful, I encountered a Chinese unicode error ..... Concept

3. pymysql

This is the solution for using django-mysql in python3 on the blog. At first, it was an unexpected success because it was not officially used...

Add:

Import pymysqlpymysql. install_as_MySQLdb () settings: DATABASES = {'default': {'Engine ': 'django. db. backends. mysql ', # Database Engine 'name': 'django', # Database NAME 'user': 'user', # username 'Password': 'password! ', # Password 'host': 'localhost', # Database HOST. The default value is localhost 'Port': '123', # Database PORT. The default value of MySQL is 3306 'options ': {'autocommit ': True ,},}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.