Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango - OperationalError: (2006, 'MySQL server has gone away')
    primarykey
    data
    text
    <p>Bottom line first: <strong>How do you refresh the MySQL connection in django?</strong></p> <p>Following a <code>MySQL server has gone away</code> error I found that <a href="http://dev.mysql.com/doc/refman/5.0/en/gone-away.html" rel="nofollow noreferrer">MySQL documentation</a> and other sources (<a href="https://stackoverflow.com/questions/2582506/2006-mysql-server-has-gone-away-in-wsgi-django">here</a>) suggest increasing the <code>wait_timeout</code> MySQL parameter. To me this seems like a workaround rather than a solution. I'd rather keep a reasonable <code>wait_timeout</code> and refresh the connection in the code.</p> <p>The error:</p> <pre><code> File "C:\my_proj\db_conduit.py", line 147, in load_some_model SomeModel.objects.update() File "C:\Python26\lib\site-packages\django-1.3-py2.6.egg\django\db\models\manager.py", line 177, in update return self.get_query_set().update(*args, **kwargs) File "C:\Python26\lib\site-packages\django-1.3-py2.6.egg\django\db\models\query.py", line 469, in update transaction.commit(using=self.db) File "C:\Python26\lib\site-packages\django-1.3-py2.6.egg\django\db\transaction.py", line 142, in commit connection.commit() File "C:\Python26\lib\site-packages\django-1.3-py2.6.egg\django\db\backends\__init__.py", line 201, in commit self._commit() File "C:\Python26\lib\site-packages\django-1.3-py2.6.egg\django\db\backends\__init__.py", line 46, in _commit return self.connection.commit() OperationalError: (2006, 'MySQL server has gone away') </code></pre> <p>Setup: Django 1.3.0 , MySQL 5.5.14 , innodb 1.1.8 , Python 2.6.6, Win7 64bit</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload