Well, I'm trying to use Peewee
for a small project. I need fields text
and url
(both longtext
in MariaDB) to be not null
and for not null
I understand not to allow a null value to be stored in the field, so I did this:
database = MySQLDatabase("mydatabase", user="", password="123justkidding", host="localhost")
class MyTable(Model):
text = TextField(null = False)
url = TextField(null = False, max_length = 100)
class Meta:
database = database
and then, of course, I created the table and I started adding values, lots of values. The thing is that there are some empty
values on text
and url
fields which I don't want them to be.
I ran this query:
SELECT `table`.`text`, `table`.`url` FROM `table` WHERE `table`.`text`="" AND `table`.`url`=""
and gave me four rows. So, What am I missing guys?
Also, I notice that MariaDB has Text, Medium Text, LongText as data-types
and it appears to me that TextField
in Peewee
is default for LongText
in MariaDB
. Any way I can change that?
Thanks in advance.
""
is empty string. NULL
is something different entirely.