django 1.8 + mysql + python 3.2

215 views
Skip to first unread message

gerard

unread,
Jul 21, 2015, 2:46:18 AM7/21/15
to django...@googlegroups.com
Hello all,
I have this combination, on debian 7 (in openvz, not possible to upgrade).
According
https://docs.djangoproject.com/en/1.8/ref/databases/#mysql-db-api-drivers,
i have to use mysqlclient or MySQL Connector/Python provided by Oracle.
Unfortunately, mysqlclient failed to work:
File
"/home/devel/.virtualenvs/python3/lib/python3.2/site-packages/django/db/backends/mysql/base.py",
line 27, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
module:
/home/devel/.virtualenvs/python3/lib/python3.2/site-packages/_mysql.cpython-32mu.so:
undefined symbol: PyUnicode_AsUTF8

and MySQL Connector/Python doesn't compile in python 3.2:
RuntimeError: Python v3.2 is not supported
tested with 2.0.4 and 2.1.2

Anybody has found a solution in this configuration?

Thanks in advance for help,

--
Gérard Henry

Tim Graham

unread,
Jul 21, 2015, 6:07:59 AM7/21/15
to django...@googlegroups.com
That configuration is not officially supported as we don't run the Django test suite with that combination. You could try the unofficial fork of MySQLdb that we recommended in the past which clams 3.2 support: https://github.com/clelland/MySQL-for-Python-3

Aron Podrigal

unread,
Jul 21, 2015, 9:40:42 AM7/21/15
to django...@googlegroups.com
I've been using mysql-connector-python==1.2.2 and django 1.6.x with no problems for the last couple of months. I had some issues before that after inactive interval the database connections are becoming invalid and was causing a server error.
I added some lines into django/db/backends/__init__.py to reconnect in that case

diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index ca58bce..79ef138 100644
--- a/django/db/backends/__init__.py
+++ b/django/db/backends/__init__.py
@@ -130,6 +130,9 @@ class BaseDatabaseWrapper(object):
         if self.connection is None:
             with self.wrap_database_errors:
                 self.connect()
+        elif not self.connection.is_connected():
+            with self.wrap_database_errors:
+                self.connect()
 
     ##### Backend-specific wrappers for PEP-249 connection methods #####
 


On Tuesday, July 21, 2015 at 2:46:18 AM UTC-4, gh224391 wrote:
Reply all
Reply to author
Forward
0 new messages