19👍
PyMySQL and MySQLdb are both database connectors for Python, libraries to enable Python programs to talk to a MySQL server.
You would normally never upload core Django files when deploying an app. If Django is working fine on your deployment server, you definitely don’t need to change anything there. The DB driver is a step or two below the ORM even, and certainly none of the code you have written depends on which of these is in use.
68👍
PyMySQL and MySQLdb provide the same functionality – they are both database connectors. The difference is in the implementation where MySQLdb is a C extension and PyMySQL is pure Python.
There are a few reasons to try PyMySQL:
- it might be easier to get running on some systems
- it works with PyPy
- it can be “greened” and works with gevent
The proper way to use it with Django is to import it and tell it to impersonate MySQLdb in your top-level file, usually manage.py. Put the following code at the very top of your manage.py (or whatever file you call when starting your server):
try:
import pymysql
pymysql.install_as_MySQLdb()
except ImportError:
pass
- [Django]-How to return custom JSON in Django REST Framework
- [Django]-Django – is not a registered namespace
- [Django]-Foreign Key Django Model
10👍
Your first point:
According to pymysql wiki page:
MySQLdb, is a C extension module that has a reputation of being
difficult to compile, especially if you’re on a Mac. Additionally,
end-users need to wait for new binaries to be compiled for each new
release of Python, and MySQLdb will never run on Jython, IronPython,
or PyPy (without something like cpyext or IronClad). We also maintain
100% compatibility between Python 2 and Python 3, so all advancements
made on the 2.x trunk will be immediately available on Python 3.
Your second point:
If django is working fine on your localhost, then it should be fine on
your development.
- [Django]-Rendering a value as text instead of field inside a Django Form
- [Django]-How to spread django unit tests over multiple files?
- [Django]-Django create userprofile if does not exist
2👍
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.
- [Django]-Django REST framework: non-model serializer
- [Django]-Giving email account a name when sending emails with Django through Google Apps
- [Django]-Distributing Django projects with unique SECRET_KEYs
0👍
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.
- [Django]-ImportError: cannot import name 'url' from 'django.conf.urls' after upgrading to Django 4.0
- [Django]-Can one use the Django database layer outside of Django?
- [Django]-Django: Safely Remove Old Migrations?