[SOLVED] Allowing null value in Peewee


I’m trying to allow null values in some columns of a MySQL database using peewee with bottle. Looking at the docs here I thought that would be quite easy. I set up a class like this:

class TestClass(MySQLModel):
Title = pw.CharField(null = True)

created the table and tried to insert a null value like this:

x = TestClass.create(Title = None)   

Only for it to hang up on me and say “_mysql_exceptions.OperationalError: (1048, "Column 'Title' cannot be null")“. Am I doing something wrong?


When table was created, said

Title = pw.Charfield(NULL = True) 

rather than

Title = pw.Charfield(null = True)

Answered By – Alex S

Answer Checked By – Candace Johnson (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *