Вопрос

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?

Это было полезно?

Решение

When table was created, said

Title = pw.Charfield(NULL = True) 

rather than

Title = pw.Charfield(null = True)
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top