Driver module installation solution based on Python3.6 using Django framework to connect MySQL database

Source: Internet
Author: User

Solution 1

Using the Pymysql module, you can use PIP install Pymysql directly.

Reference article: https://www.cnblogs.com/wcwnina/p/8719482.html

Original content:

Python3 does not support MYSQLDB and can be replaced with Pymysql. CMD installation pymysql:pip install Pymysql. Add the following code to the _init_.py under the project folder.  Import  pymysqlpymysql.install_as_mysqldb () and then perform the database Migration command in terminal: Python manage.py Makemigrationspython manage.py Migrate

Solution 2

This article strongly recommends the use of the implementation of the method. Because of the Pymysql module in Method 1, there may be some bugs that are difficult to solve due to module problems in the project's subsequent operation of the MySQL database.

It is recommended to use the Mysqlclient module here. Note that Python3 is not able to install mysqlclient directly using PIP install Mysqlclient, but Python2 can do so. So Python3 how to properly install the Mysqlclient module? You need to install two front-facing packages here, as follows:

(1) sudo apt-get install Python-dev Libmysqlclient-dev # Debian/ubuntu

(2) sudo apt-get install Python3-dev # Debian/ubuntu

The above two-step installation statement is installed on the Ubuntu system, windows or CentOS system, and the command is matched against the replacement.

After installing the two Libmysqlclient-dev, python3-dev front package, and then using the PIP install Mysqlclient can be successfully installed on the Python3.

Original link: Https://github.com/PyMySQL/mysqlclient-python

Driver module installation solution based on Python3.6 using Django framework to connect MySQL database

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.