import mysql.connector import traceback host = '127.0.0.1' port = 3306 username = 'FIXME' password = 'FIXME' database = 'FIXME' def get_new_connection(): connection = mysql.connector.connect(host = host, user = username, passwd = password, port = port, autocommit = True, connect_timeout = 30, compress = False) connection.database = database return connection connection = get_new_connection() cursor = connection.cursor() cursor.execute("DROP TABLE IF EXISTS big") cursor.execute("""CREATE TABLE big ( a LONGTEXT NOT NULL ) ENGINE=Innodb DEFAULT CHARSET utf8""") cursor.execute("INSERT INTO big VALUES (rpad('a', 8388605, 'a'))") cursor.execute("UPDATE big SET a = concat(a,a)") print "16777210 bytes" cursor.execute("SELECT * FROM big") results = cursor.fetchall() cursor.execute("UPDATE big SET a = concat(a,'a')") try: print "16777211 bytes" cursor.execute("SELECT * FROM big") results = cursor.fetchall() except IndexError, e: print traceback.format_exc() connection = get_new_connection() cursor = connection.cursor() cursor.execute("UPDATE big SET a = concat(a,'a')") try: print "16777212 bytes" cursor.execute("SELECT * FROM big") results = cursor.fetchall() except TypeError, e: print traceback.format_exc() print "Done"