I got this error when I execute my query
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in de
faulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (2006, 'MySQL server has gone away')
I read this question, this one and this one and this one
I read the Doc and I know that I got this error because image_name
in my query is too large
You can also get these errors if you send a query to the server that is too large.
I set a limite for the length of my variable
image_name = (image_name[:180]) if len(image_name) > 180 else image_name
cmd = "UPDATE `banners` SET `checked` = '1',`local_dir` = %s , `image_name` = %s WHERE `unique_id` = %s "
cursor.execute(cmd,[local_addr,image_name,unique_id])
And I set also max_allowed_packet
in /etc/my.cnf
[mysqld]
max_allowed_packet=16M
Do you have any idea how can I avoid this error?