when users double clicks the messagebox appears and when they click yes then the sold column is updated to yes but this doesnt save to the database?

from tkinter import messagebox
import tkinter as tk
from tkinter import ttk
import sqlite3

class Database:
def init(self):
self.conn = sqlite3.connect(“items.db”)
self.cur = self.conn.cursor()
self.create_table()

def create_table(self):
    # Check if the table already exists
    self.cur.execute('''SELECT count(name) FROM sqlite_master WHERE type='table' AND name='items' ''')
    if self.cur.fetchone()[0] == 0:
        # Table doesn't exist, create it along with the IsSold column
        self.cur.execute('''CREATE TABLE IF NOT EXISTS items (
                            ItemId INTEGER PRIMARY KEY,
                            Item TEXT,
                            SizeNumeric TEXT,
                            Size TEXT,
                            Year TEXT,
                            Price REAL,
                            Condition TEXT,
                            IsSold INTEGER )''')
        self.conn.commit()
   

def insert_item(self, item, size_numeric, size, year, price, condition):
    # SQL query to insert an item into the table
    self.cur.execute('''INSERT INTO items (Item, SizeNumeric, Size, Year, Price, Condition, IsSold) 
                        VALUES (?, ?, ?, ?, ?, ?, ?)''', (item, size_numeric, size, year, price, condition, 0))
    self.conn.commit()  

def close(self):
    self.conn.close()  # Closes the connection when done

code for add item page

from tkinter import messagebox

class BuyItemPage:
def init(self, master):
self.master = master
master.title(“Buy Item”)
master.configure(bg=”#A7C7E7″)

    # Set the initial size of the window
    master.geometry("600x600")

    # Create a Treeview widget
    self.create_treeview()

    # Fetch items from the database and insert them into the Treeview
    self.populate_treeview()

def create_treeview(self):
    # Create a Treeview widget
    self.treeview = ttk.Treeview(self.master)

    # Add columns
    self.treeview['columns'] = ('Item ID', 'Item', 'SizeNumeric', 'Size', 'Year', 'Price', 'Condition', 'Sold')

    # Define column headings
    self.treeview.heading('Item ID', text='Item ID', anchor=tk.CENTER)
    self.treeview.heading('Item', text='Item', anchor=tk.CENTER)
    self.treeview.heading('SizeNumeric', text='SizeNumeric', anchor=tk.CENTER)
    self.treeview.heading('Size', text='Size', anchor=tk.CENTER)
    self.treeview.heading('Year', text='Year', anchor=tk.CENTER)
    self.treeview.heading('Price', text='Price', anchor=tk.CENTER)
    self.treeview.heading('Condition', text='Condition', anchor=tk.CENTER)
    self.treeview.heading('Sold', text='Sold', anchor=tk.CENTER)

    # Pack the Treeview
    self.treeview.pack(expand=True, fill='both')

    # Bind double click event to the Treeview
    self.treeview.bind("<Double-1>", self.on_item_double_click)

def populate_treeview(self):
    # Connect to the database
    conn = sqlite3.connect("items.db")
    cursor = conn.cursor()

    # Fetch items from the database
    cursor.execute("SELECT * FROM items")
    items = cursor.fetchall()

    # Fetch unique categories from the database
    cursor.execute("SELECT DISTINCT Item FROM items")
    categories = [row[0] for row in cursor.fetchall() if row[0]]  # Exclude empty categories

    # Close the database connection
    conn.close()

    # Clear existing items from the Treeview
    self.treeview.delete(*self.treeview.get_children())

    # Dictionary to store items by category
    categorized_items = {category: [] for category in categories}

    # Organize items into categories
    for item in items:
        category = item[1]  # Assuming the second column represents the category
        if category in categorized_items:
            categorized_items[category].append(item)

    # Populate the Treeview with categorized items
    for category, items in categorized_items.items():
        category_item = self.treeview.insert('', 'end', text=category, tags=("Category.Text",))
        for item in items:
            self.treeview.insert(category_item, 'end', values=item)

def on_item_double_click(self, event):
    selected_item = self.treeview.selection()[0]
    # Retrieve Item ID from the selected item
    item_id = self.treeview.item(selected_item)['values'][0]
    
    # Retrieve the item name for displaying in the messagebox
    item_name = self.treeview.item(selected_item)['values'][1]

    # Display a messagebox confirmation
    response = messagebox.askyesno("Buy Now", "Buy Item")

    if response:  # If the user clicks "Yes"
        self.mark_as_sold(item_id)

def mark_as_sold(self, item_id):
    # Update the Treeview to reflect the change
    selected_item = self.treeview.selection()[0]
    self.treeview.set(selected_item, column='Sold', value='Yes')

rest of code

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật