Django1.7+python 2.78+pycharm Configuring MySQL Database tutorial

Source: Internet
Author: User
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,
},
}
}

  • 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.