On Wed, Dec 7, 2011 at 12:56 PM, Jannis Leidel <lei...@gmail.com> wrote:

>
> Ian,
>
> > This is a proposal to add support in Django for PyMySQL[1] as an
> optional replacement for MySQLdb.
> >
> > I've been working with Vinay Sajip's Python 3-compatible branch; trying
> to get MySQL support working, and I have had a great deal of success, using
> PyMySQL as a back end, rather than MySQLdb.
> >
> > MySQLdb does not support Python3, and I haven't seen any indication
> online that it will be supporting Python3 any time soon.
>
> That's not entirely true actually, I talked to Andy Dustman (MySQLdb's
> author earlier this year while researching the bits needed for porting) and
> he mentioned that several people ported it over the Python 3:
>
> -
> http://sourceforge.net/projects/mysql-python/forums/forum/70460/topic/3831691
> - https://github.com/davispuh/MySQL-for-Python-3
>
> Quoting him from his private reply: "I use 1.2.3 regularly with Django, so
> if there's serious interest in a Python 3 version, I'll try to find the
> time and energy to work on it again."
>
> As to which of those unofficial ports is the "correct" one, I can't help.
> But it would certainly be helpful to get in touch with Andy before
> dismissing MySQLdb altogether.
>
>
That's great to hear, that there's still at least some motivation to move
that project forward.

My goal has been to help Vinay out with his Python 3 drive, by debugging
the MySQL backend, and dropping this adapter in has been a way to at least
get the rest of the backend code exercised.


> > PyMySQL is a pure python implementation of PEP 249 for MySQL, and
> supports Python 2.4 - 3.2, and MySQL 4.1 and higher. It is nearly a
> plug-in-replacement for MySQLdb  (although there are a few compatibility
> issues that I have tried to take care of in Django backend code)
> >
> > My approach so far has been to patch django/db/backends/mysql:
> >    - Try to import MySQLdb, and then MySQLdb.converters and
> MySQLdb.constants.
> >    - If that fails, try to import pymysql, and pymysql.converters and
> pymysql.constants
> >    - Whichever succeeds, set a module-level variable 'backend' to
> indicate the backend that we are using.
> >
> >    - Patch the data-type conversions appropriately, depending on the
> backend that was used.
> >
> > So far, that's it -- and I'm down to just a couple of unit test
> failures, but those may even be Python3 issues; I haven't tracked them all
> down yet.
> >
> > My questions, then:
> >
> > 1. Is PyMySQL appropriate for django-core, in the opinion of the core
> devs? There isn't another stable Python 3-compatible mysql adapter, as far
> as I know, and I don't think Django could move to Python 3 support without
> at least the currently-supported databases.
>
> I think it's better to ask whether it's appropriate to switch the backend
> library while doing the Python version jump. In my opinion it's not given
> the stability MySQLdb has shown over the years. At least I'm not seeing
> reasons to get rid of it.
>

Well, it sounds like moving Django to Python 3, even with MySQLdb support,
would necessitate a simultaneous upgrade in MySQLdb anyway -- if there's no
official version right now that support both 2 and 3, then we would have to
upgrade both at the same time. Appreciated, though, that MySQLdb has a
longer history, but it would still be at least some new code.

And I wasn't trying to get rid of it, rather to support both of them at the
same time, given that they have the same interface, and only a few internal
differences, which can be smoothed over in module initialization.


>
> > 2. Is this the right approach? I know that in the past, we have had
> multiple backends for PostgreSQL, in different modules under
> django.db.backends, but in this case, the modules are almost 100%
> compatible, except for the module names themselves, and the calling
> conventions for the data conversions. It feels more like the situation with
> JSON libraries, where we just load whichever one is available, and present
> the same outward api to the developer.
>
> IMO it's not, database backends vary in the way to speak to the database,
> so if -- and only if it's really needed to introduce another backend for
> MySQL -- it should be independent from the current one.
>
> > 3. Code speaks, I know -- what's the best way to share this? I've sent
> Vinay a patch, but that's for his Py3k branch, and might not get the
> audience that something like this needs. I'm doing it for Py3k support, but
> ideally it would work just as well under Python 2.x. Should I set up a
> public repository somewhere, or just open a ticket and attach patches?
>
> I asked Martin von Löwis who maintains the Py3K branch in Django official
> SVN repo to review Vinay's changes and merge them, as long as you manage to
> get patches in line with their work I think we're fine.
>

Jannis
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers" group.
> To post to this group, send email to django-developers@googlegroups.com.
> To unsubscribe from this group, send email to
> django-developers+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-developers?hl=en.
>
>


-- 
Regards,
Ian Clelland
<clell...@gmail.com>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to