diff --git a/app.py b/app.py index 122aeca..5e53836 100644 --- a/app.py +++ b/app.py @@ -15,7 +15,8 @@ class App(Tk): def __init__(self): Tk.__init__(self) self._frame = None - self.switch_frame(Past_Purchase_Page) + #self.switch_frame(Past_Purchase_Page) + self.switch_frame(customerItem_Page) def switch_frame(self, frame_class): new_frame = frame_class(self) diff --git a/customerItem.py b/customerItem.py index edc8232..ed10972 100644 --- a/customerItem.py +++ b/customerItem.py @@ -8,20 +8,15 @@ class customerItem_Page(Frame): def __init__(self, master): Frame.__init__(self, master) self.master = master - - def show(): - conn = sqlite3.connect('products.db') + getProducts() - c = conn.cursor() - - c.execute(''' - SELECT * FROM products - ''', ['']) - - for product in c.fetchall(): - print(product) - - conn.commit() - conn.close() - - filter_btn = Button(self, text="FILTER", command = show) \ No newline at end of file + def getProducts(): + my_conn = sqlite3.connect('products.db') + r_set=my_conn.execute('''SELECT * from products'''); + i=0 # row value inside the loop + for product in r_set: + for j in range(len(product)): + e = Entry(self, width=10, fg='blue') + e.grid(row=i, column=j) + e.insert(END, product[j]) + i=i+1 \ No newline at end of file diff --git a/data.py b/data.py index f879bc7..ed5ef15 100644 --- a/data.py +++ b/data.py @@ -23,11 +23,11 @@ INSERT INTO products VALUES (?,?,?,?,?,?) ''', [row['Category'], - row['Cost ($)'], + row['Cost'], row['Model'], - row['Price ($)'], + row['Price'], row['ProductID'], - row['Warranty (months)']] + row['Warranty']] ) # cursor.execute(''' diff --git a/product_data.py b/product_data.py deleted file mode 100644 index b902ba2..0000000 --- a/product_data.py +++ /dev/null @@ -1,36 +0,0 @@ -import sqlite3 -import sqlite3 -import json - -with open('products.json') as f: - data = json.load(f) - -conn = sqlite3.connect('products.db') - -cursor = conn.cursor() - -cursor.execute(''' -CREATE TABLE items ( - Category TEXT, - Cost INTEGER, - Model TEXT, - Price INTEGER, - ProductID INTEGER, - Warranty INTEGER); -''') - -for row in data: - cursor.execute(''' - INSERT INTO items VALUES (?,?,?,?,?,?) - ''', - [row['Category'], - row['Cost'], - row['Model'], - row['Price'], - row['ProductID'], - row['Warranty']] - ) - -conn.commit() - -conn.close() \ No newline at end of file diff --git a/products.db b/products.db index 7ea8f4f..0250929 100644 Binary files a/products.db and b/products.db differ diff --git a/test.py b/test.py index 46ed74f..5c0a8d6 100644 --- a/test.py +++ b/test.py @@ -1,6 +1,6 @@ import sqlite3 -connection = sqlite3.connect('items.db') +connection = sqlite3.connect('products.db') cursor = connection.cursor() -cursor.execute('SELECT * FROM products WHERE ItemID < 1005') +cursor.execute('SELECT * FROM products') print(cursor.fetchall()) \ No newline at end of file