Re: MySQL, Django 1.6, Python3

1,017 views
Skip to first unread message

Aymeric Augustin

unread,
Mar 11, 2013, 4:29:22 AM3/11/13
to django-d...@googlegroups.com
On 11 mars 2013, at 00:32, Norberto Bensa <nbe...@gmail.com> wrote:

> I wanted to run Django with Python 3 but mysql was a showstopper until today.


Hi Norberto,

Since MySQLdb wasn't ported to Python 3 yet, this isn't officially supported at this time.

I've filed a ticket so we don't forget to deal with this in 1.6: https://code.djangoproject.com/ticket/20025

Maybe MySQLdb will be ported to Python 3 by then, maybe there'll be a solid alternative that we can use. Otherwise we'll document that Django cannot be used with MySQL on Python 3.

--
Aymeric.



Anton

unread,
Mar 11, 2013, 1:38:32 PM3/11/13
to django-d...@googlegroups.com
hi,

I was also asking myself if it would be possible
to use django 6 python 3 and mysql.

Development on mysqldb seems to have paused, so another quesetion:

Why not use the mysql connectors from mysql directly:

http://www.mysql.com/downloads/connector/python/#downloads

They support python 3.3 too.

It seems that oracle has rediscovered python,
but no one knows how long.

Anton

Norberto Bensa

unread,
Mar 13, 2013, 12:36:12 AM3/13/13
to django-d...@googlegroups.com
Hi!


On Monday, March 11, 2013 5:29:22 AM UTC-3, Aymeric Augustin wrote:
On 11 mars 2013, at 00:32, Norberto Bensa <nbe...@gmail.com> wrote:

> I wanted to run Django with Python 3 but mysql was a showstopper until today.


Hi Norberto,

Since MySQLdb wasn't ported to Python 3 yet, this isn't officially supported at this time.


There's a port. You didn't read the whole message :-(

 


Ok. Small projects (very small), but it works (for me).



I've filed a ticket so we don't forget to deal with this in 1.6: https://code.djangoproject.com/ticket/20025


Can I update the ticket?

 Thanks!

Aymeric Augustin

unread,
Mar 13, 2013, 3:30:40 AM3/13/13
to django-d...@googlegroups.com, django-d...@googlegroups.com
Le 13 mars 2013 à 05:36, Norberto Bensa <nbe...@gmail.com> a écrit :

On Monday, March 11, 2013 5:29:22 AM UTC-3, Aymeric Augustin wrote:
On 11 mars 2013, at 00:32, Norberto Bensa <nbe...@gmail.com> wrote:

Since MySQLdb wasn't ported to Python 3 yet, this isn't officially supported at this time.

There's a port. You didn't read the whole message :-(

I did read your whole message. I never reply to a message before reading it entirely.

I meant that MySQLdb hasn't been officially ported.


That's a fork of a fork, and it's hard to tell how much testing it has received. I'm unable evaluate if it's a good idea to bless it at this point.

There've been experimental forks and ports of Django to Python 3, and only a handful of people ever tested them (they suffered from a bunch of issues which real-world testing in an non-ascii environment would have revealed).

I've filed a ticket so we don't forget to deal with this in 1.6: https://code.djangoproject.com/ticket/20025


Can I update the ticket?

The tracker is public, of course you can comment on any ticket without asking for permission!

-- 
Aymeric.

VernonCole

unread,
Mar 14, 2013, 3:22:31 AM3/14/13
to django-d...@googlegroups.com
This thread interacts with another current thread: the one about MS-SQL database support. As I mentioned there, adodbapi is capable of accessing any ODBC compliant data source. MySQL is one of those.  adodbapi is Python 3 compliant, and I have been using MySQL databases from Python 3 for several years.

If django supported adodbapi as a connection method -- separated from its use as a connection method specifically for the Microsoft SQL engine -- then it could also be used to reach MySQL and any other database engine people needed.  I should be able to use adodbapi rather than psycopg2, for example, if the hooks were in place.  On Linux, I should be permitted to select a prominent commercial ODBC product to do the same job, if I wanted to.

At the present time, the specification of the database engine is implied by selecting the backend in settings.py.  There is no convenient way of saying "I expect to be using connection method "X" to hook with engine "Y".  The driver-to-engine coupling has always been one-to-one.  I suspect that there are places deep withing django where this simplification has been used to advantage.  However, the two things should really be uncoupled.  Is it important?  No.  Might it have some presently unforseen advantages? I suspect so.

If the two Oracle database interfaces were to be re-tasked as supported options, rather than part of the core, then the driver-to-engine coupling would become looser. In the end, it ought to be possible for the selection of the engine to be deferred until after the database is actually connected.  Neither ADO nor ODBC actually know which engine they are talking to until the connection is complete.  After connection, I can look at the connection.dbms_name attribute and I can see which engine I am connected to.  If  the engine turns out to be postgresql, should I not be able to hook to the correct SQL compiler and have everything just work?

Then, with this looser coupling, We could separate the testing (and support) of different engines on different operating systems on different Python versions.
--
Vernon Cole

On Sunday, March 10, 2013 5:32:02 PM UTC-6, Norberto Bensa wrote:
Hello,

I wanted to run Django with Python 3 but mysql was a showstopper until today. Thanks to G+ I found a few links of interest:





So I git-cloned django and m4p3 but I got a problem.


'use_unicode' is an invalid keyword argument for this function
Request Method:GET
Request URL:http://localhost:8080/propietario/
Django Version:1.6.dev20130310222819
Exception Type:TypeError
Exception Value:
'use_unicode' is an invalid keyword argument for this function
Exception Location:/home/ubuntu/.virtualenvs/test3/git/MySQL-for-Python-3/MySQLdb/connections.py in __init__, line 175
Python Executable:/home/ubuntu/.virtualenvs/test3/bin/python
Python Version:3.2.3



I thought, well, let's disable use_unicode in my settings.py. I added OPTIONS: { 'use_unicode': False } to DATABASES.default, but no way. Same error. So I patched django/db/backends/mysql/base.py:DatabaseWrapper:get_connection_params() and commented 'use_unicode':True. And now I can use Django, Mysql, and Python 3


The question is: Is there any option I'm overlooking and this mix can be used with patching Django or is Mysql+python3 just not supported (for now)?


Thanks!
Norberto

Reply all
Reply to author
Forward
0 new messages