Cannot update database with placeholders in sqlite3

27 Views Asked by At
def save_task_changes(self):
    con = sqlite3.connect("revisiontimetable.db")
    cur = con.cursor()
    date = self.calendarWidget.selectedDate().toPyDate()

    #changes to checkboxes
    for i in range(self.dayListWidget.count()):
        item = self.dayListWidget.item(i)
        task = item.text()
        print("Task: ", task)
        print("Date: ", date)
        if item.checkState() == Qt.CheckState.Checked:
            query = ("UPDATE Tasks SET CheckState = 'YES' WHERE task = ? AND date = ?")
            print("In Checked Box")
            print("Update Query: ", query)
        # else:
        #     query = "UPDATE Tasks SET CheckState = 'NO' WHERE task = ? AND date = ?"
        #     print("Checked Box")
            value = (task, date)
            cur.execute(query, value)
            result = cur.execute("SELECT * FROM Tasks")
            print("Checkbox res: ", result.fetchone())
    con.commit()

Essentially, I am trying to update changes to the QListWidget, if I tick a checkbox for a particular item I need this to update in the db, but I am having trouble with this

0

There are 0 best solutions below