[Django] #22391: fallback to pymysql if MySQLdb not available

102 views
Skip to first unread message

Django

unread,
Apr 5, 2014, 4:55:08 PM4/5/14
to django-...@googlegroups.com
#22391: fallback to pymysql if MySQLdb not available
----------------------------------------------+--------------------
Reporter: CollinAnderson | Owner: nobody
Type: New feature | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
Currently, pymysql is the best-supported mysql adapter on python 3.
However, users need to use the following trick to get it to work with
django:

{{{
try:
import pymysql
pymysql.install_as_MySQLdb()
except ImportError:
pass
}}}

I think it would help python 3 adoption if users could use django and
pymysql without additional steps.

--
Ticket URL: <https://code.djangoproject.com/ticket/22391>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 5, 2014, 4:59:47 PM4/5/14
to django-...@googlegroups.com
#22391: fallback to pymysql if MySQLdb not available
-------------------------------------+-------------------------------------

Reporter: CollinAnderson | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by CollinAnderson):

* needs_docs: => 0
* has_patch: 0 => 1
* needs_tests: => 0
* needs_better_patch: => 0


Comment:

https://github.com/django/django/pull/2520

--
Ticket URL: <https://code.djangoproject.com/ticket/22391#comment:1>

Django

unread,
Apr 6, 2014, 3:21:05 AM4/6/14
to django-...@googlegroups.com
#22391: fallback to pymysql if MySQLdb not available
-------------------------------------+-------------------------------------

Reporter: CollinAnderson | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by loic84):

* stage: Unreviewed => Accepted


Comment:

I agree it'd be nice to have support for pymysql, and I actually worked on
it a little while ago before giving up.

I don't think a fallback mechanism is the right approach though, I'd much
prefer a minimal yet separate db backend that'd leverage most of the
implementation of the default backend.

Did you manage to get the test suite to work with this patch? I remember
running into a lot of issues when I tried.

--
Ticket URL: <https://code.djangoproject.com/ticket/22391#comment:2>

Django

unread,
Apr 6, 2014, 4:14:30 AM4/6/14
to django-...@googlegroups.com
#22391: fallback to pymysql if MySQLdb not available
-------------------------------------+-------------------------------------

Reporter: CollinAnderson | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by aaugustin):

Related: #12500.

--
Ticket URL: <https://code.djangoproject.com/ticket/22391#comment:3>

Django

unread,
Apr 6, 2014, 3:57:30 PM4/6/14
to django-...@googlegroups.com
#22391: fallback to pymysql if MySQLdb not available
-------------------------------------+-------------------------------------

Reporter: CollinAnderson | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by anonymous):

I have also a dedicated branch for this:
https://github.com/claudep/django/tree/pymysql. However, I think the test
suite does not entirely pass with that patch.

--
Ticket URL: <https://code.djangoproject.com/ticket/22391#comment:4>

Django

unread,
Apr 6, 2014, 7:40:52 PM4/6/14
to django-...@googlegroups.com
#22391: fallback to pymysql if MySQLdb not available
-------------------------------------+-------------------------------------

Reporter: CollinAnderson | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by CollinAnderson):

It looks like testing against the latest version of pymysql, 0.6.1
(October 2013), there are some errors, but, using pymysql's master branch,
there are at least fewer errors. Some recent things that have been fixed
are Thing2Literal and query encoding. I also have a pull request in to fix
dates before 1900. It looks like there's a ticket open for timezone
support.

It seems to me we should try to fix pymysql as much as possible to try to
get it compatible with MySQLdb, and then require the latest version of
pymysql.

Also, I'm personally interested in also using pymysql on python2.7, so I
would prefer the fallback approach myself. Though, it's clear the real
benefit of this is for python 3.

--
Ticket URL: <https://code.djangoproject.com/ticket/22391#comment:5>

Django

unread,
Apr 9, 2014, 8:15:16 AM4/9/14
to django-...@googlegroups.com
#22391: fallback to pymysql if MySQLdb not available
-------------------------------------+-------------------------------------

Reporter: CollinAnderson | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by CollinAnderson):

My "fix dates before 1900" change just merged.
https://github.com/PyMySQL/PyMySQL/pull/232

--
Ticket URL: <https://code.djangoproject.com/ticket/22391#comment:6>

Django

unread,
Jun 5, 2014, 6:56:03 PM6/5/14
to django-...@googlegroups.com
#22391: fallback to pymysql if MySQLdb not available
-------------------------------------+-------------------------------------

Reporter: CollinAnderson | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1

Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: 0 => 1


Comment:

Maybe this needs discussion on the mailing list for a resolution. One
question I have is how we are going to ensure that it doesn't break if we
merge it to core. Do we need another MySQL build to the Jenkins matrix?

--
Ticket URL: <https://code.djangoproject.com/ticket/22391#comment:7>

Django

unread,
Jun 9, 2014, 11:11:46 AM6/9/14
to django-...@googlegroups.com
#22391: fallback to pymysql if MySQLdb not available
-------------------------------------+-------------------------------------

Reporter: CollinAnderson | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0

Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by CollinAnderson):

* needs_better_patch: 1 => 0


Comment:

My branch merges cleanly again.
https://github.com/django/django/pull/2520#issuecomment-45358916
https://github.com/collinanderson/django/compare/ticket_22391

--
Ticket URL: <https://code.djangoproject.com/ticket/22391#comment:8>

Django

unread,
Aug 7, 2014, 12:00:42 PM8/7/14
to django-...@googlegroups.com
#22391: fallback to pymysql if MySQLdb not available
-------------------------------------+-------------------------------------

Reporter: CollinAnderson | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by CollinAnderson):

* cc: cmawebsite@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/22391#comment:9>

Django

unread,
Aug 12, 2014, 3:25:05 AM8/12/14
to django-...@googlegroups.com
#22391: fallback to pymysql if MySQLdb not available
-------------------------------------+-------------------------------------

Reporter: CollinAnderson | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1

Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by akaariai):

* needs_better_patch: 0 => 1


Comment:

If I understand correctly we at least need CI support for testing pymysql
builds? Also, if In understand correctly there are still some errors with
pymysql?

The best way forward is to ask for CI support for pymysql builds on
django-developers mailing list.

I'll set patch needs improvement for lack of better marker that this
ticket isn't ready for merge.

--
Ticket URL: <https://code.djangoproject.com/ticket/22391#comment:10>

Django

unread,
Aug 12, 2014, 12:24:50 PM8/12/14
to django-...@googlegroups.com
#22391: fallback to pymysql if MySQLdb not available
-------------------------------------+-------------------------------------

Reporter: CollinAnderson | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by collinanderson):

Sorry, I should link to the django-developers ghost-thread, and maybe bump
it. https://groups.google.com/d/topic/django-
developers/n-TI8mBcegE/discussion

--
Ticket URL: <https://code.djangoproject.com/ticket/22391#comment:11>

Django

unread,
Nov 4, 2014, 5:35:24 PM11/4/14
to django-...@googlegroups.com
#22391: fallback to pymysql if MySQLdb not available
-------------------------------------+-------------------------------------

Reporter: CollinAnderson | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by timgraham):

Do we still need this now that we have support for mysqlclient (with no
changes to Django)?

--
Ticket URL: <https://code.djangoproject.com/ticket/22391#comment:12>

Django

unread,
Nov 4, 2014, 8:15:13 PM11/4/14
to django-...@googlegroups.com
#22391: fallback to pymysql if MySQLdb not available
-------------------------------------+-------------------------------------
Reporter: CollinAnderson | Owner: nobody
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) | Resolution: wontfix

Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by collinanderson):

* status: new => closed
* resolution: => wontfix


Comment:

I think I'm fine with closing for now, though I still think pymysql is
quite popular due to it being pure python.

--
Ticket URL: <https://code.djangoproject.com/ticket/22391#comment:13>

Reply all
Reply to author
Forward
0 new messages