├── README.md ├── Students.db ├── backend.py ├── frontend.exe ├── frontend.py └── screenshots ├── 1. Hello world.PNG ├── 2. View All.PNG ├── 3. Search (Ahmed).PNG ├── 4.1 Enter new student data.PNG ├── 4.2. Add New.PNG ├── 5.1. Select a student to update.PNG ├── 5.2. Update.PNG ├── 6.1. Select a student to delete.PNG ├── 6.2. Delete.PNG ├── 7. Clear.PNG ├── 8. Delete all Students.PNG └── 9. Add New student after deleting the old database.PNG /README.md: -------------------------------------------------------------------------------- 1 | # Student-database-management-system 2 | 3 | A simple **GUI project** made with **tkinter** and **sqlite3** for **Students Database Management System**. 4 | 5 | ## Table of Content 6 | 7 | 1. [Introduction](#introduction) 8 | 2. [Screenshots](#screenshots) 9 | 3. [Instructions](#instructions) 10 | 1. [Requirements](#requirements) 11 | 2. [Execution](#execution) 12 | 3. [Standalone App](#standalone-app) 13 | 14 | ## Introduction 15 | In this project, you can do the following: 16 | 1. Add new student. 17 | 2. Update a specific student. 18 | 3. Delete a specific student. 19 | 4. Search for a specific student or multiple students by 20 | * First Name 21 | * Last Name 22 | * Term 23 | * GPA 24 | 5. Display all database 25 | 6. Delete the database 26 | 27 | ## Screenshots 28 | Kindly, check the [screenshots folder](https://github.com/AhMeDxHaMiDo/Student-database-management-system/tree/master/screenshots) to get an overview about the software. 29 | 30 | ## Instructions 31 | 32 | #### Requirements 33 | * Python 3 34 | * tkinter 35 | * sqlite3 36 | 37 | * Ex: 38 | ``` 39 | pip install 40 | ``` 41 | 42 | #### Execution 43 | * Use `frontend.py` to run the software. 44 | 45 | #### Standalone App 46 | * To convert any script to Standalone App: 47 | 1. Install pyinstaller package 48 | * `pip install pyinstaller` 49 | 2. Run the command: 50 | * `pyinstaller --onefile --windowed frontend.py` 51 | 52 | * [**The Standalone App for that Project**](https://github.com/AhMeDxHaMiDo/Student-database-management-system/blob/master/frontend.exe) 53 | -------------------------------------------------------------------------------- /Students.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmedxomar101/Student-database-management-system/5139ecc2d51f4b8faeebc7f5dfe6fbd969673ff8/Students.db -------------------------------------------------------------------------------- /backend.py: -------------------------------------------------------------------------------- 1 | import sqlite3 2 | import os 3 | 4 | 5 | def connect(): 6 | ''' Create a database if not existed and make a connection to it. 7 | 8 | ''' 9 | conn = sqlite3.connect("Students.db") 10 | cur = conn.cursor() 11 | cur.execute("CREATE TABLE IF NOT EXISTS data1 (id Integer PRIMARY KEY, fn TEXT, ln TEXT, term INTEGER, gpa REAL)") 12 | conn.commit() 13 | conn.close() 14 | 15 | def insert(fn,ln,term,gpa): 16 | ''' insertion function to insert a new student to the database. 17 | 18 | Arguments 19 | --------- 20 | fn: str, Student First Name. 21 | ln: str, Student Last Name. 22 | term: int, Student Term. 23 | gpa: float, Student GPA. 24 | ''' 25 | conn = sqlite3.connect("Students.db") 26 | cur = conn.cursor() 27 | cur.execute("INSERT INTO data1 Values (NULL,?,?,?,?)",(fn,ln,term,gpa)) 28 | conn.commit() 29 | conn.close() 30 | 31 | def view(): 32 | ''' view function to show the content of the database 33 | which is the student data. 34 | returns the content of the database. 35 | ''' 36 | conn = sqlite3.connect("Students.db") 37 | cur = conn.cursor() 38 | cur.execute("SELECT * FROM data1") 39 | rows = cur.fetchall() 40 | conn.close() 41 | return rows 42 | 43 | def search(fn="",ln="",term="",gpa=""): 44 | ''' search function to search for a specific student in the database. 45 | returns the content of the database. 46 | 47 | Arguments 48 | --------- 49 | fn: str, Student First Name. 50 | ln: str, Student Last Name. 51 | term: str, Student Term. 52 | gpa: str, Student GPA. 53 | ''' 54 | conn = sqlite3.connect("Students.db") 55 | cur = conn.cursor() 56 | cur.execute("Select * FROM data1 WHERE fn=? or ln=? or term=? or gpa=?",(fn,ln,term,gpa)) 57 | rows = cur.fetchall() 58 | conn.close() 59 | return(rows) 60 | 61 | def delete(id): 62 | ''' delete function to delete a specific student from the database. 63 | 64 | Arguments 65 | --------- 66 | id: int, id of the student in the database. 67 | ''' 68 | conn = sqlite3.connect("Students.db") 69 | cur = conn.cursor() 70 | cur.execute("DELETE FROM data1 WHERE id=?",(id,)) 71 | conn.commit() 72 | conn.close() 73 | 74 | def update(id,fn,ln,term,gpa): 75 | ''' update function to update the data of a specific student in the database 76 | by their id. 77 | 78 | Arguments 79 | --------- 80 | id: int, id of the student in the database. 81 | fn: str, updated Student First Name. 82 | ln: str, updated Student Last Name. 83 | term: int, updated Student Term. 84 | gpa: float, updated Student GPA. 85 | ''' 86 | conn = sqlite3.connect("Students.db") 87 | cur = conn.cursor() 88 | cur.execute("UPDATE data1 SET fn=?, ln=?, term=?, gpa=? WHERE id=?",(fn,ln,term,gpa,id)) 89 | conn.commit() 90 | conn.close() 91 | 92 | def delete_data(): 93 | ''' delete_data function is to delete the database. 94 | 95 | ''' 96 | if os.path.exists("Students.db"): 97 | os.remove("Students.db") 98 | connect() 99 | 100 | connect() 101 | -------------------------------------------------------------------------------- /frontend.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmedxomar101/Student-database-management-system/5139ecc2d51f4b8faeebc7f5dfe6fbd969673ff8/frontend.exe -------------------------------------------------------------------------------- /frontend.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | import backend 3 | 4 | 5 | def get_selected_row(event): 6 | ''' get_selected_row function to get content of the selected row. 7 | 8 | Arguments 9 | --------- 10 | event: a virtual interrupt. 11 | ''' 12 | global selected_tuple 13 | if lb1.curselection() != (): 14 | 15 | index = lb1.curselection()[0] 16 | selected_tuple = lb1.get(index) 17 | clear_entries() 18 | e1.insert(END,selected_tuple[1]) 19 | e2.insert(END,selected_tuple[2]) 20 | e3.insert(END,selected_tuple[3]) 21 | e4.insert(END,selected_tuple[4]) 22 | 23 | def view_command(): 24 | ''' view_command function to show the output database. 25 | 26 | ''' 27 | lb1.delete(0,END) 28 | for row in backend.view(): 29 | lb1.insert(END,row) 30 | 31 | def search_command(): 32 | ''' search_command function to search in the database. 33 | 34 | ''' 35 | lb1.delete(0,END) 36 | for row in backend.search(fn.get(),ln.get(),term.get(),gpa.get()): 37 | lb1.insert(END,row) 38 | clear_entries() 39 | 40 | def add_command(): 41 | ''' add_command function to add a new student to the database. 42 | 43 | ''' 44 | backend.insert(fn.get(),ln.get(),term.get(),gpa.get()) 45 | clear_entries() 46 | view_command() 47 | 48 | def update_command(): 49 | ''' update_command function to update the data of a specific student. 50 | 51 | ''' 52 | backend.update(selected_tuple[0],fn.get(),ln.get(),term.get(),gpa.get()) 53 | clear_entries() 54 | view_command() 55 | 56 | def delete_command(): 57 | ''' delete_command function to delete the data of a specific student. 58 | 59 | ''' 60 | index = lb1.curselection()[0] 61 | selected_tuple = lb1.get(index) 62 | backend.delete(selected_tuple[0]) 63 | clear_entries() 64 | view_command() 65 | 66 | def delete_data_command(): 67 | ''' delete_data_command function to delete the database. 68 | 69 | ''' 70 | backend.delete_data() 71 | view_command() 72 | 73 | def clear_entries(): 74 | ''' clear_entries function to clear content of entries. 75 | 76 | ''' 77 | e1.delete(0,END) 78 | e2.delete(0,END) 79 | e3.delete(0,END) 80 | e4.delete(0,END) 81 | 82 | def clear_command(): 83 | ''' view_command function to clear content of Listbox. 84 | 85 | ''' 86 | lb1.delete(0,END) 87 | clear_entries() 88 | 89 | wind = Tk() 90 | 91 | fn = StringVar() 92 | ln = StringVar() 93 | term = StringVar() 94 | gpa = StringVar() 95 | 96 | l0 = Label(wind, text = "Students", width = "10", fg = "blue") 97 | l0.config(font=("Courier", 15)) 98 | 99 | l00 = Label(wind, text = "Database", width = "10", fg = "blue") 100 | l00.config(font=("Courier", 15)) 101 | 102 | l1 = Label(wind, text = "First Name", width = "10") 103 | l2 = Label(wind, text = "Last Name", width = "10") 104 | l3 = Label(wind, text = "Term", width = "10") 105 | l4 = Label(wind, text = "GPA", width = "10") 106 | 107 | e1 = Entry(wind, textvariable =fn) 108 | e2 = Entry(wind, textvariable =ln) 109 | e3 = Entry(wind, textvariable =term) 110 | e4 = Entry(wind, textvariable =gpa) 111 | 112 | b1 = Button(wind, text = "View all", width = "15", command = view_command) 113 | b2 = Button(wind, text = "Search", width = "15", command = search_command) 114 | b3 = Button(wind, text = "Add New", width = "15", command = add_command) 115 | b4 = Button(wind, text = "Update", width = "15", command = update_command) 116 | b5 = Button(wind, text = "Delete", width = "15", command = delete_command) 117 | b6 = Button(wind, text = "Clear", width = "15", command = clear_command) 118 | b7 = Button(wind, text = "Delete all Students", width = "15", command = delete_data_command) 119 | b8 = Button(wind, text = "Exit", width = "15", command = wind.destroy) 120 | 121 | lb1 = Listbox(wind, height = 6, width = 35) 122 | lb1.bind('<>',get_selected_row) 123 | 124 | sc = Scrollbar(wind) 125 | 126 | l0.grid(row=0,column=1) 127 | l00.grid(row=0,column=2) 128 | l1.grid(row=1,column=0) 129 | l2.grid(row=1,column=2) 130 | l3.grid(row=2,column=0) 131 | l4.grid(row=2,column=2) 132 | 133 | e1.grid(row=1,column=1) 134 | e2.grid(row=1,column=3) 135 | e3.grid(row=2,column=1) 136 | e4.grid(row=2,column=3) 137 | 138 | b1.grid(row=3,column=3) 139 | b2.grid(row=4,column=3) 140 | b3.grid(row=5,column=3) 141 | b4.grid(row=6,column=3) 142 | b5.grid(row=7,column=3) 143 | b6.grid(row=8,column=3) 144 | b7.grid(row=9,column=3) 145 | b8.grid(row=10,column=3) 146 | 147 | lb1.grid(row=4, column=0,rowspan=8, columnspan=2) 148 | 149 | sc.grid(row=4,column=2,rowspan=8) 150 | 151 | lb1.configure(yscrollcommand=sc.set) 152 | sc.configure(command=lb1.yview) 153 | 154 | wind.mainloop() 155 | -------------------------------------------------------------------------------- /screenshots/1. Hello world.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmedxomar101/Student-database-management-system/5139ecc2d51f4b8faeebc7f5dfe6fbd969673ff8/screenshots/1. Hello world.PNG -------------------------------------------------------------------------------- /screenshots/2. View All.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmedxomar101/Student-database-management-system/5139ecc2d51f4b8faeebc7f5dfe6fbd969673ff8/screenshots/2. View All.PNG -------------------------------------------------------------------------------- /screenshots/3. Search (Ahmed).PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmedxomar101/Student-database-management-system/5139ecc2d51f4b8faeebc7f5dfe6fbd969673ff8/screenshots/3. Search (Ahmed).PNG -------------------------------------------------------------------------------- /screenshots/4.1 Enter new student data.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmedxomar101/Student-database-management-system/5139ecc2d51f4b8faeebc7f5dfe6fbd969673ff8/screenshots/4.1 Enter new student data.PNG -------------------------------------------------------------------------------- /screenshots/4.2. Add New.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmedxomar101/Student-database-management-system/5139ecc2d51f4b8faeebc7f5dfe6fbd969673ff8/screenshots/4.2. Add New.PNG -------------------------------------------------------------------------------- /screenshots/5.1. Select a student to update.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmedxomar101/Student-database-management-system/5139ecc2d51f4b8faeebc7f5dfe6fbd969673ff8/screenshots/5.1. Select a student to update.PNG -------------------------------------------------------------------------------- /screenshots/5.2. Update.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmedxomar101/Student-database-management-system/5139ecc2d51f4b8faeebc7f5dfe6fbd969673ff8/screenshots/5.2. Update.PNG -------------------------------------------------------------------------------- /screenshots/6.1. Select a student to delete.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmedxomar101/Student-database-management-system/5139ecc2d51f4b8faeebc7f5dfe6fbd969673ff8/screenshots/6.1. Select a student to delete.PNG -------------------------------------------------------------------------------- /screenshots/6.2. Delete.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmedxomar101/Student-database-management-system/5139ecc2d51f4b8faeebc7f5dfe6fbd969673ff8/screenshots/6.2. Delete.PNG -------------------------------------------------------------------------------- /screenshots/7. Clear.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmedxomar101/Student-database-management-system/5139ecc2d51f4b8faeebc7f5dfe6fbd969673ff8/screenshots/7. Clear.PNG -------------------------------------------------------------------------------- /screenshots/8. Delete all Students.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmedxomar101/Student-database-management-system/5139ecc2d51f4b8faeebc7f5dfe6fbd969673ff8/screenshots/8. Delete all Students.PNG -------------------------------------------------------------------------------- /screenshots/9. Add New student after deleting the old database.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmedxomar101/Student-database-management-system/5139ecc2d51f4b8faeebc7f5dfe6fbd969673ff8/screenshots/9. Add New student after deleting the old database.PNG --------------------------------------------------------------------------------