mod_python/MySQL error on INSERT with a lot of data: "OperationalError: (2006, 'MySQL server has gone away')"

When doing an INSERT with a lot of data, ie:

INSERT INTO table (mediumtext_field) VALUES ('...lots of text here: about 2MB worth...')

MySQL returns

"OperationalError: (2006, 'MySQL server has gone away')"

This is happening within a minute of starting the script, so it is not a timeout issue. Also, mediumtext_field should be able to hold ~16MB of data, so that shouldn't be a problem.

Any ideas what is causing the error or how to work around it?

Some relevant libraries being used: mod_python 3.3.1, MySQL 5.0.51 (on Windows XP SP3, via xampp, details below)

ApacheFriends XAMPP (basic package) version 1.6.5

  • Apache 2.2.6
  • MySQL 5.0.51
  • phpMyAdmin 2.11.3


Asked by: Grace230 | Posted: 24-09-2021






Answer 1

check the max_packet setting in your my.cnf file. this determines the largest amount of data you can send to your mysql server in a single statement. exceeding this values results in that error.

Answered by: Alissa310 | Posted: 25-10-2021



Similar questions

python - Getting OperationalError: FATAL: sorry, too many clients already using psycopg2

I am getting the error OperationalError: FATAL: sorry, too many clients already when using psycopg2. I am calling the close method on my connection instance after I am done with it. I am not sure what could be causing this, it is my first experience with python and postgresql, but I have a few years experience with php, asp.net, mysql, and sql server. EDIT: I am running this locally, if the connections are closing ...


mysql - Python and mySQLdb error: OperationalError: (1054, "Unknown column in 'where clause'")

Hey all, I'm getting an error OperationalError: (1054, "Unknown column 'XX' in 'where clause'") Where XX is the value of CLASS in the following code conn = MySQLdb.connect(host = "localhost",user = "user", passwd = "pass",db = "dbase") cursor = conn.cursor() cursor.execute("""SELECT * FROM %s WHERE course =%s AND sec = %s""" % (str(DEPT),str(CLASS),str(SEC),))


python - OperationalError: foreign key mismatch

I have two tables that I'm filling, 'msrun' and 'feature'. 'feature' has a foreign key pointing to the 'msrun_name' column of the 'msrun' table. Inserting in the tables works fine. But when I try to delete from the 'feature' table I get the following error: pysqlite2.dbapi2.OperationalError: foreign key mismatch From the rules of foreign keys in the manual of SQLite: - The ...


python - Missing mysql.sock; yielding OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")

Firstly, I swear that I have looked at every single question that references this error. Nearly every solution someone offers is different, and no one seems to understand the systemic reasons for the error. What I, and many people on the web who encounter this common problem, need, is an explanation of what is actually going wrong. Basically, when I try to run: python manage.py shell from django.db...


python - Flask OperationalError: unable to open database file using sqlite3

I'm trying to hook an existing sqlite3 db to a dashboard I'm building and I've run into a problem that I can't figure out how to resolve. I've been working on this by trying to piece together things from the Flask docs and other sources, so feel free to call me out on anything in here that looks a little odd. It probably is, and I just don't know it :) Code: from __future__ import with_statement fro...


python - Why am I suddenly getting "OperationalError: no such table"?

I am trying to do various things with my database. I've connected and pulled data out and out data in, successfully, no problems. I've been debugging other issues, and then suddenly I can no longer get anything from my database table - I'm getting "OperationalError: no such table: article". I'm really stumped here - this was working just fine, I was querying the db with no problems and inserting data, etc etc. T...


python - Inserting JSON data to sqlite - OperationalError: unrecognized token "{"

I'm doing something like this in my code: import sqlite3 ... sqlString=company['name']+","+simplejson.dumps(info) cur.execute("INSERT INTO companyInfo VALUES("+sqlString+")") but I'm getting the following error: cur.execute("INSERT INTO companyBlobs VALUES("+valueString+")") sqlite3.OperationalError: unrecognized token: "{" I guess this is a problem with the escaping of the...


python - Django on vagrant, psycopg2 OperationalError: could not connect to server: No such file or directory

On vagrant box, installed postgres via apt-get install python-psycopg2. Tested import successfully. $ python Python 2.6.5 (r265:79063, Oct 1 2012, 22:04:36) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import psycopg2 >>> exit() Django settings file: DATABASES = { 'default': { '...


python - SQLite3 OperationalError: Table XYZ has no column named ABC

I am new to peewee, so please forgive me if this is a stupid question. I have searched on Google and in the peewee cookbook, but found no solution so far. So, I have the following models to four of my DB tables: class games_def(Model): id = PrimaryKeyField() name = TextField() class Meta: database = dbmgr.DB class users_def(Model): id = PrimaryKeyField() first_name = Tex...


Python MySQL OperationalError: 1045, "Access denied for user root@'localhost'

I was trying to access the database from my python program by: db = mysql.connect(host = 'localhost', user = 'Max', passwd = 'maxkim', db = 'TESTDB') cursor = db.cursor() But, I get an error message in the first line of code. OperationalError: (1045, "Access denied for user 'Max'@'localhost' (using password: YES)") To remedy the situation, I did the follow...






Still can't find your answer? Check out these communities...



PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python



top