I recently installed the django framework ( v1.7.4 ) and the mysql database
connector ( pymysql ) for python. It is my understanding that the MySQLdb
python connector is depreciated and is no longer available for download
through PIP . However I installed pymysql which is an alternate download
for MySQLdb connector for python. The connector (pysql) works with the
MySQL database installed but my current django installation does not work
because I recieve errors about missing MySQLdb module.
However despite the setback trying to use the MySQLdb package I was able to
make changes to the installed django package (
django/db/backends/mysql/base.py ) that
help to make my django projects functional and error free now.
I hope this will help those in the Django community, whom are affected by
the same errors that I was recieving.
Thanks
Below I have outlined some of the changes I made to my django package are
as follows:
####Updates made in base.py (The base.py is locate in the django package)
####Path to base.py inside the django package ( django/db/backends/mysql/ )
import pymysql as Database#MySQLdb as Database
from pymysql.converters import conversions, Thing2Literal
from pymysql.constants import FIELD_TYPE, CLIENT
### line 30 - 31 replaced MySQLdb for pymysql
### line 15 replaced MySQLdb for pymysql
#from MySQLdb.converters import conversions, Thing2Literal
#from MySQLdb.constants import FIELD_TYPE, CLIENT
Below is a snippet installing MySQLdb connector using PIP
C:\Users\root\Documents\GitHub\djangoproject-tutorial\tutorial> pip install
mysqldb
Downloading/unpacking mySQLdb
Could not find any downloads that satisfy the requirement mySQLdb
Cleaning up...
No distributions at all found for mySQLdb
Storing debug log for failure in C:\Users\root\pip\pip.log
C:\Users\root\Documents\GitHub\djangoproject-tutorial\tutorial>
Below is a snippet of the Django-1.7.4 interacting with the pymysql
connector
File
"C:\Users\root\Documents\GitHub\djangoproject-tutorial\tutorial\lib\site-packages\django\db\backends\mysql\base.py"
, line 18, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module:
No module named 'MySQLdb'
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/aac9808f-ca9f-4b57-96f4-086704267761%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.