-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabasegui.py
More file actions
33 lines (26 loc) · 896 Bytes
/
Copy pathdatabasegui.py
File metadata and controls
33 lines (26 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import tkinter as tk
import sqlite3
from tkinter import ttk, messagebox
class SQLiteGUI:
def __init__(self, root):
self.root = root
self.root.title("SQLite GUI")
# Create a connection to the SQLite database
self.conn = sqlite3.connect("mydatabase.db")
self.cursor = self.conn.cursor()
# Create GUI elements
self.create_widgets()
def display_data(self):
# Clear any existing data in the treeview
for row in self.tree.get_children():
self.tree.delete(row)
# Fetch data from the database
self.cursor.execute("SELECT * FROM StockRecord")
rows = self.cursor.fetchall()
# Insert data into the treeview
for row in rows:
self.tree.insert("", tk.END, values=row)
if __name__ == "__main__":
root = tk.Tk()
app = SQLiteGUI(root)
root.mainloop()