Marian Marian - 2 months ago 4x
MySQL Question

InterfaceError (0, '')

I have built a site using Django and I am receiving this annoying error when I am trying to execute a query.

If I restart the Apache server, the error will go away for a short time.

File "/usr/local/lib/python2.7/site-packages/django/core/handlers/" in get_response
100. response = callback(request, *callback_args, **callback_kwargs)
File "/home/fran/cron/views/" in set_caches
24. cursor.execute(query, [category['id']])
File "/usr/local/lib/python2.7/site-packages/django/db/backends/" in execute
15. return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/" in execute
86. return self.cursor.execute(query, args)
File "build/bdist.linux-i686/egg/MySQLdb/" in execute
155. charset = db.character_set_name()

Exception Type: InterfaceError at /blablabla/
Exception Value: (0, '')


This is caused by a global cursor. Try creating and closing the cursor within each method a raw query is needed.

cursor = connection.cursor()