I'm trying to using the following code insert a long string into a
MySQL table, the data type is of that column is TEXT. When the length
of the content is longer than 65K, it get truncated in the database.
Any idea about this?  Thanks

import MySQLdb
import MySQLdb.cursors

class MyDb:
    def __init__(self):
        self.conn = None
        self.cursor = None

    def connect(self):
        self.conn = MySQLdb.Connect(
            host='localhost', user='user',
            passwd='password', db='testdb',compress=1,
            cursorclass=MySQLdb.cursors.DictCursor)
        self.cursor = self.conn.cursor()

    def insert(self, id, content):
        try:
            self.cursor.execute("INSERT INTO `my_table`(`id`,
`content`) VALUES (%s, %s);", (id, content));
        except:
            print "Failed to insert new record"
            pass
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to