I am inserting data to MySQL via SQLAlchemy models. Recently, this app is running against MySQL configured with STRICT_TRANS_TABLES
and app fails occasionally because of Data too long for column error.
I know that I can disable strict sql_mode for my session (like here MySQL too long varchar truncation/error setting),
but I was curious if SQLAlchemy can enforce max String() length for column data. Documentation says, the String()
length is for CREATE TABLE
only. My question:
- Is it possible to enforce max length (truncate too long strings) in SQLAlchemy?
- Can I set it for individual columns or for all columns in all tables/database only?