DB won't update?

Viewed 28

This is my code:

def edit_books(self):
    #connect to sql server
    self.db = MySQLdb.connect(host='localhost', user='root', password='Mistro 1994', db='library')
    self.cur = self.db.cursor()
    

    #get data
    book_title = self.book_title_search.text()
    description = self.edit_plainTextEdit.toPlainText() 
    book_code = self.book_code.text()
    book_categeory = self.category_comboBox.currentText()
    book_author =  self.author_comboBox.currentText()
    book_publisher = self.publisher_comboBox.currentText()
    book_price = self.book_price.text()
    
    data = (book_title, description, book_code, book_categeory, \
        book_author, book_publisher, book_price, book_title)
    
    insert_statement = "UPDATE book SET book_name=%s ,book_description=%s \
        ,book_code=%s , book_category=%s, book_author=%s, \
            book_publisher=%s, book_price=%s WHERE book_name = %s"

    self.cur.execute(insert_statement, data)

    self.db.commit()
    print('save', end='\n')
    print(data)
0 Answers
Related