Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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?

like image 262
Alex S Avatar asked Sep 20 '13 22:09

Alex S


1 Answers

When table was created, said

Title = pw.Charfield(NULL = True) 

rather than

Title = pw.Charfield(null = True)
like image 55
Alex S Avatar answered Sep 18 '22 21:09

Alex S