Issue
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:
myDB.connect()
x = TestClass.create(Title = None)
x.save()
Only for it to hang up on me and say “_mysql_exceptions.OperationalError: (1048, "Column 'Title' cannot be null")
“. Am I doing something wrong?
Solution
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)