Issue
For my toggle of a Boolean value with Flask and SQLite I want to change 1 into 0 and 0 into 1 on table engineering_project
. The message can be successfully flashed so the if function is working. However, the value of engg_proj_status
in the table cannot be updated:
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")
Solution
Add conn.commit()
Thanks to this comment from forpas.
Answered By - AsM
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.