In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail the example analysis of Django2.* + Mysql5.7 development environment integration. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Environment:
MAC_OS 10.12
Python 3.6
Mysql 5.7.25
Django 2.2.3
Premise: python django mysql has been successfully installed and can be run separately
I. Database configuration in settings
DATABASES = {'default': {' ENGINE': 'django.db.backends.mysql', "USER": "user name", "PASSWORD": "your password", "NAME": "db name"}}
two。 Replace the default database driver
1. Install pymysql
Pip3 install pymysql
two。 Replace the driver
Find the main package of the project, such as the project called TEST, find the _ _ init__.py file under the TEST package
Add the following code:
Import pymysqlpymysql.install_as_MySQLdb ()
three。 Problem solving:
Problem 1 problem with the version of Magi mysqlclient
"" django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. "
Solution: follow the path in the figure to find the corresponding lines 35 and 36, and comment them out.
Question 2: string codec problem
"" AttributeError: 'str' object has no attribute' decode' ""
Solution: click on the exception tracking information, find line 146in operations.py, and change decode to encode:
Test run:
PS: the reason for modifying the source code guess is the compatibility between django2 and python3 and pymysql. In addition, 2.* is chosen because of the official support time.
Django default database driver is mysqlclient, but found in the test, completely unable to run, mysql various link libraries failed to import!.
This is the end of the article on "sample Analysis of Django2.* + Mysql5.7 Development Environment Integration". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.