Updating sqlalchemy with boolean value from form : <p>I'm trying to update a row in a database table with a value from a wtforms BooleanField. When creating the row, it's inserted into the database with no problem, but when updating I get the error below.</p>

<p>When reading around this issue, it seems it's something to do with the initalising of the type of Boolean value the database should accept. In my sqlite db, the column contains 1/0, but I'm not sure how to fix it. It seems strange that the initial insert is fine, but updates are not. wtforms documentation mentions that the checked.data in the HTML returns a True or False value.</p>

<pre><code>class Question(PaginatedAPIMixin, db.Model):
    __tablename__ = 'question'
    ...
    answer_space = db.Column(db.Boolean, server_default="False")
    ...

class QuestionForm(FlaskForm):
    ...
    answer_space = BooleanField('Generate space for question answer automatically?',default="checked")
    ...

# inside add question route
if form.validate_on_submit():
        question = Question(body=form.body.data,
                            answer_space=form.answer_space.data, 
                            author=current_user,
                            exam_level = form.exam_level.data, 
                            exam_board=form.exam_board.data, 
                            exam_year=form.exam_year.data,
                            exam_session=form.exam_session.data,
                            marks=form.marks.data, 
                            answer=form.answer.data,
                            )
        ...    
        db.session.add(question)
        db.session.commit()

#inside update question route
if form.validate_on_submit():
        question.body = form.body.data
        question.answer_space = form.answer_space.data,
        question.exam_board=form.exam_board.data
        question.exam_level = form.exam_level.data
        question.exam_year=form.exam_year.data
        question.exam_session=form.exam_session.data
        question.marks=form.marks.data
        question.answer=form.answer.data

        ...

        db.session.commit()
        flash('Your changes have been saved.', 'success')
        return redirect(url_for('main.view_questions'))
</code></pre>

<p>sqlalchemy.exc.StatementError: (builtins.TypeError) Not a boolean value: False
[SQL: UPDATE question SET exam_session=?, answer_space=? WHERE question.id = ?]
[parameters: [{'answer_space': (False,), 'exam_session': '1', 'question_id': 12}]]</p>
