Skip to content Skip to sidebar Skip to footer

Why Does Sqlalchemy Boolean Column Fail With "typeerror: An Integer Is Required, Found Str"

Here's an answer your own question to help other out who may also hit this error. I'm using SQLite3 from Python and using SQLAlchemy to load my objects via the ORM. I have a column

Solution 1:

Turns out the problem was the default value. Booleans in SQLAlchemy map to integers in the DB (I did create the right type of column) but the default value of FALSE wasn't translated via the DDL command to an integer value of 0.

The fix is to create the column as so:

ALTERTABLE Users ADD the_column INTEGERDEFAULT0NOTNULL;

Post a Comment for "Why Does Sqlalchemy Boolean Column Fail With "typeerror: An Integer Is Required, Found Str""