'Cannot update SQL Boolean value with flask and sqlite3
I have developed a simple switch to change the value of the Boolean value with flask + SQLite.
I want to change 1 into 0 and change 0 into 1 on table engineering_project.
The message can be successfully flashed in each case so it means that the if function is working normally.
However, the value of engg_proj_status in the table cannot be updated.
engg_proj_status cotains either 0 or 1.
I still can't figure out what went wrong.
conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row
c = conn.cursor()
c.execute("SELECT engg_proj_status FROM engineering_project WHERE engg_proj_id =?",(engg_proj_id,))
status = c.fetchone()[0]
if status == 1:
c.execute("UPDATE engineering_project SET engg_proj_status = ? WHERE engg_proj_id = ?;",(False,engg_proj_id))
flash("Status changed from COMPLETED to OPEN")
else:
c.execute("UPDATE engineering_project SET engg_proj_status = ? WHERE engg_proj_id = ?;",(True,engg_proj_id))
flash("Status changed from OPEN to COMPLETED")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
