2019-10-14T15:24:42Z

Video: Four SQLAlchemy Tips

Posted by Miguel Grinberg under Database, Python.

6 comments

  • #1 Tiago said 2019-10-16T19:56:17Z

    Great tips. Thanks Miguel.

  • #2 James said 2019-11-25T21:16:14Z

    Hi Miguel, I followed your flask-mega-tutorial to develop an internal employee directory app. But I'm having an issue with SQLIte and MySQL when it comes to storing output from a WYSIWYG editor. While developing I used SQLite like you recommended in your tutorial. I used the Text() type to store the HTML data from the editor, which worked fine for me. But once I deployed to our server and over to MySQL I started getting "Data too long for column" errors for any output longer than a few sentences. Do you know if there are any significant differences between SQLite and MySQL that would cause this issue? Thanks!

  • #3 Miguel Grinberg said 2019-11-25T22:58:29Z

    @James: SQLite is not strict with lengths, but MySQL is. Are you sure this is for a column of type Text? My guess is that this problem is for a String or similar column where you either didn't specify a size or the size is small compared to the content you are writing to the column.

  • #4 James said 2019-11-26T20:56:01Z

    @Miguel: No It's definitely set to Text *about_me = db.Column(db.Text)* It is possible that I need to set a length for Text as well?

  • #5 James said 2019-11-26T21:37:27Z

    @Miguel: So an quick update. It looks like I'm running up against some 140 character limit in my strings for Text. If I go passed that I get the "Data is too long" error.

  • #6 Miguel Grinberg said 2019-11-27T14:14:26Z

    @James: are you sure the model agrees with what's in the database? Please check the database schema using a MySQL admin tool. I think you must have had the 140 character limit in the past, or in a migration file. If you changed from 140 to unlimited that needs a new database migration.

Leave a Comment