Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - What is the purpose of defining the maximum string length in an SQLAlchemy model?

Just curious because it doesn't seem to stop a longer string from being stored in the DB like I expected it to.

Why even define it if it doesn't matter? (it must do something!)

class Message(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    tag = db.Column(db.String(12))
    description = db.Column(db.String(120))
    copy = db.Column(db.String)
    voice = db.Column(db.String(24))
like image 300
Chockomonkey Avatar asked Oct 01 '22 10:10

Chockomonkey


1 Answers

As Daniel suggested, I'm using SQLite, which does not enforce column lengths.

Thanks Daniel!

like image 66
Chockomonkey Avatar answered Oct 04 '22 21:10

Chockomonkey