large insert strings crash MySQL

scott cotton scott at chronis.pobox.com
Mon May 31 01:51:49 EDT 1999


I believe the problem is with one of the buffer sizes the
server is set to run with.  check out the performance tuning
docs on the mysql www home or run 'mysqladmin variables' to
find out what they are and change them on the command line
for mysqld. that should work, but you may find that the
amount of mem used by each mysqld process gets big fast
accomodating such things. 

scott

On Sun, May 30, 1999 at 01:10:52PM -0700, jesse at spine.com wrote:
| 
| I'm trying to insert large strings (up to several meg) into a mysql
| table via python and MySQL.  My table defines item_data as a longblob:
| 
| mysql> show fields from item;
| +-------------+------------------+------+-----+---------+----------------+
| | Field       | Type             | Null | Key | Default | Extra          |
| +-------------+------------------+------+-----+---------+----------------+
| | item_id     | int(10) unsigned |      | PRI | 0       | auto_increment |
| | item_data   | longblob         | YES  |     | NULL    |                |
| ...
| 
| 
| 
| and I'm able to insert large strings from the mysql client:
| 
| mysql> insert into item (item_id, item_name, item_data) 
|        values (null, 'tmp', repeat('x', 80000));
| Query OK, 1 row affected (0.88 sec)
| 
| 
| 
| but when I try it from MySQL it fails with an error:
| 
| >>> db = MySQL.connect('localhost','user','pass')
| >>> db.selectdb('kb')
| >>> bs = 'x' * 40000
| >>> db["insert into item (item_id, item_name, item_data) 
|     values (null, 'tmp', '%s')" % bs]
| 1
| >>> bs = 'x' * 80000
| >>> db["insert into item (item_id, item_name, item_data) 
|     values (null, 'tmp', '%s')" % bs]
| Traceback (innermost last):
|   File "<stdin>", line 1, in ?
| MySQL.error: MySQL server has gone away
| 
| 
| Any suggestions?  It looks like it's treating it as a normal blob with
| a 64k limit.
| 
| 
| -- 
| http://www.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list