I know about the boolean
column type, but is there a boolean
literal in SQLite? In other languages, this might be true
You can use BOOLEAN
when creating a table:
sqlite3 :memory:
SQLite version 3.22.0 2018-01-22 18:45:57
Enter ".help" for usage hints.
sqlite> CREATE TABLE test (mybool BOOLEAN);
But this is not a real datatype and on the SQL description of the table we will have something like this:
"mybool" BOOLEAN NOT NULL CHECK(mybool IN(0,1))
Basically we create an SQL constrain constrain that the value should be 0 or 1. And therefore using TRUE/FALSE will pop an error:
sqlite> INSERT INTO test(mybool) VALUES (TRUE);
Error: no such column: TRUE
So, we can use the key word BOOLEAN
but have to use 0/1 since it is not a "real" datatype.
When working with sqlalchemy we can use the datatype BOOLEAN without any problems