PyMySQL이란 무엇이며 MySQLdb와 어떻게 다릅니까? Django 배포에 영향을 줄 수 있습니까?
나는 방금 내 Django 1.3 앱의 몇 가지 문제를 PyMy로 해결했다.MySQLdb가 아닌 SQL입니다.스위치를 만드는 방법에 대해서는, 다음의 튜토리얼을 따릅니다.http://web-eng-help.blogspot.com/2010/09/install-mysql-5-for-python-26-and.html
이제 PyMy가 무엇인지 알고 싶습니다.SQL은 실제로 MySQLdb와 어떻게 다른지 확인합니다.
로컬 호스트에서 사용하고 있으며, 그 후 호스팅에 업로드합니다.
PyMy를 사용해도 될까요?로컬 호스트 상의 SQL과 그들이 제공하는 모든 것을 호스팅하는 SQL?base.py 및 introspection.py에서 "MySQLdb"를 "PyMySQL"로 변경했으므로 파일을 변경한 후 서버에 업로드해야 합니까?아니면 장고의 파일이기 때문에 장고는 이미 업로드 되어 있기 때문에 크게 문제가 되지 않는 것입니까?
PyMySQL과 MySQLdb는 모두 데이터베이스 커넥터로 동일한 기능을 제공합니다.차이점은 MySQLdb가 C 확장이고 PyMy가 구현되어 있다는 점입니다.SQL은 순수 Python입니다.
PyMy를 시도하는 데는 몇 가지 이유가 있습니다.SQL:
- 일부 시스템에서 실행하는 것이 더 쉬울 수 있습니다.
- PyPy와 연동됩니다.
- "녹색"이 가능하며 Gevent와 함께 작동합니다.
Django와 함께 사용하는 적절한 방법은 Import한 후 최상위 파일(일반적으로 manage.py에서 MySQLdb를 가장하도록 지시하는 것입니다.manage.py 의 맨 위(또는 서버를 기동할 때에 호출하는 파일)에, 다음의 코드를 입력합니다.
try:
import pymysql
pymysql.install_as_MySQLdb()
except ImportError:
pass
PyMySQL과 MySQLdb는 모두 Python용 데이터베이스 커넥터로 Python 프로그램이 MySQL 서버와 통신할 수 있도록 하는 라이브러리입니다.
일반적으로 앱을 배포할 때 핵심 장고 파일을 업로드하지 않습니다.Django가 전개 서버에서 정상적으로 동작하고 있는 경우는, 거기서 아무것도 변경할 필요가 없습니다.DB 드라이버는 ORM보다 1~2단계 아래이며, 사용 중인 코드에 따라 작성되는 코드는 없습니다.
첫 번째 포인트:
pymysql wiki 페이지에 따르면:
MySQLdb는 컴파일이 어려운 것으로 유명한 C 확장 모듈입니다. 특히 Mac을 사용하는 경우 그렇습니다.또한 최종 사용자는 Python의 새 릴리스마다 새로운 바이너리가 컴파일될 때까지 기다려야 하며 MySQLdb는 Jython, IronPython 또는 PyPy(cpyext 또는 IronClad와 같은 것)에서 실행되지 않습니다.또한 Python 2와 Python 3의 100% 호환성을 유지하고 있으므로 2.x 트렁크에서 이루어진 모든 고급 기능은 Python 3에서 즉시 사용할 수 있습니다.
Your second point:
If django is working fine on your localhost, then it should be fine on your development.
As per my experience I had difficulty in installing "MySQL-python" - (MySQLdb). It made me search for more alternatives so I found pymysql, and it also got installed easily and worked in first go like a charm. So I would suggest using pymysql only instead of MySQLdb.
I am starting with these topic, I only want to say an observation: PyMSQL has CPYTHON as a requirement(is optionall perhaps for performance https://pypi.org/project/PyMySQL/#requirements) to install, and Cpyhton depend on 'C', I tested Cpython and I had trouble when installed for the version of C too... then both implementation depend on 'C' [if you want performance], is the same thing for me...if the performance is not problem, perhaps PyMySQL is good without Cpython, free of 'C'. Perhaps we can start with PyMySQL alone with Python and switch Python to Cpython to gain in performance that could be a good thing we have all the things running and after that we can try to switch to Cpython,,, We need to know the funcionality difference. Why in Django PyMySQL run better for you or give to you solutions for some problems, what problems? That is the important thing for change perhaps. MySQLdb perhaps depend directly from 'C' but PyMSQL indirectly thru Cpython(in case of similar performance), I prefer a direct dependence without limitations of jumps...Greetings.
ReferenceURL : https://stackoverflow.com/questions/7224807/what-is-pymysql-and-how-does-it-differ-from-mysqldb-can-it-affect-django-deploy
'programing' 카테고리의 다른 글
오브젝트가 python에서 generator 오브젝트인지 확인하는 방법 (0) | 2022.09.11 |
---|---|
브라우저의 JavaScript에서 SQL Server 데이터베이스에 연결하는 방법 (0) | 2022.09.11 |
c - 경고: 함수의 암묵적 선언 'printf' (0) | 2022.09.09 |
Python에서 max-heap을 구현하려면 무엇을 사용해야 합니까? (0) | 2022.09.09 |
Larabel 5.2에서 전화번호를 확인하는 방법 (0) | 2022.09.09 |