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:
>
> 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
>
--
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/214179f5-a5bf-48c1-9732-1d7dfbd88bc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.