Reputation: 10764
I have a model like this
class mymodel(Base):
"""
Unprocessed DataSource model
"""
__tablename__ = 'mymodel_data'
mod_id = Column(Integer, primary_key=True)
mod_name = Column(Unicode(150))
user_id = Column(Integer, ForeignKey('users.user_id'))
all_data = Column(UnicodeText)
The all_data
is a long json text and the size of it can be very very very long.
Sometimes the data gets truncated and the error MSG I get is
Warning: Data truncated for column 'all_data' at row 1
I need to make sure that the truncation does not happen or I need a workaround. Is there a way? I tried reading this article but I could not figure out what to do.
I am using mysql
Upvotes: 2
Views: 2692
Reputation: 133919
I guess that on MySQL, the TEXT type is used by default. It has the limit of 64K characters. SQLAlchemy will choose a different type to match the given length argument. As MEDIUMTEXT has an arbitrary limit at 16M, and LONGTEXT (max 4G characters) requires just 1 byte more, you could always use the LONGTEXT for these columns (or use UnicodeText(length=2**31)
).
Upvotes: 3
Reputation: 10764
Guess I figured it out. I can specify a length for the unicodeText argument. Sorry for the noob question
Upvotes: 1