Let python 3 support the mysqldb solution, pythonmysqldb

Source: Internet
Author: User

Let python 3 support the mysqldb solution, pythonmysqldb

Preface

In the new year, I wish you all use ES6 at the front end, PHP7 for php, JAVA9 for Java, and 3 for python. Now, the main content of this article is as follows. You may have used mysqldb in python2.x, but this component is not supported in python3.x. What if I want python 3 to support mysqldb? Let's take a look.

Cause

MySQLdb is only applicable to python2.x, and pip cannot be installed. Its alternatives in py3 are:Import pymysql

Pip install pymysqldjango + mysql

By default, Django still uses MySQLdb: The execution reports:ImportError: No module named 'mysqldb'

Solution:

In_ Init _. pyFile

Import pymysqlpymysql. install_as_MySQLdb ()

Summary

The above is all the content of this article. I hope the content of this article will help you in your study or work. If you have any questions, please leave a message, thank you for your support.

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.