MySQL longtext column type

1,719 views
Skip to first unread message

jonEbird

unread,
Jan 7, 2009, 10:31:08 AM1/7/09
to sqlalchemy
I am building a application which will accept a variable sized string
input as one of my columns and I have already had cases where the
maximum size of 65536 for a MySQL 'text' column was too small and the
data is being truncated. I am having a problem trying to coerce
sqlalchemy into using a longtext column type with my backend MySQL
database. I have tried the following with my Table definition: (2^32)
Column('data', Text(4294967296), nullable=False)
and it continues to define the column as a 'text' type. Only when I
use:
Column('data', MSLongText(), nullable=False)
does it actually create my table with the longtext column.

I would like to be DB agnostic and avoid using the MySQL specific
MSLongText type if possible. What am I missing?

Thanks,
Jon Miller

sqlalchemy version 0.5.0rc4
mysql version 5.0.67
python 2.5

Michael Bayer

unread,
Jan 7, 2009, 3:25:40 PM1/7/09
to sqlal...@googlegroups.com
similar to something we just did with MSSQL regarding Binary, we'd
need to add a MSGenericText type that issues any number of TEXT types
when asked for DDL, based on the length present.

Michael Bayer

unread,
Jan 9, 2009, 8:13:13 PM1/9/09
to sqlal...@googlegroups.com
Ive created ticket #1275 in trac:

http://www.sqlalchemy.org/trac/ticket/1275

for this issue, but our MySQL maintainer Jason Kirtland explains there
that the TEXT type in MySQL does in fact handle values up to
4294967295 for length, which on the MySQL side will automatically
perform the translation to LONGTEXT when the column is created (he
says your example is just off by one byte too much). Can you please
confirm this is the case for you and we can close the ticket.

On Jan 7, 2009, at 10:31 AM, jonEbird wrote:

>

jonEbird

unread,
Jan 13, 2009, 10:29:08 AM1/13/09
to sqlalchemy
Indeed, you are correct.
When I use the adjusted statement of:
Column('data', Text(4294967295), nullable=False)
The column type was created as longtext. Sorry for the trouble, I
thought I had tried that before.

Thank you,
Jon Miller
Reply all
Reply to author
Forward
0 new messages