-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (37 loc) · 1.45 KB
/
main.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import SQLib
import backend
SQLib.createTable()
print("Library Management system created by Abhinav Pant, under GNU General Public License.")
# Asking the user to add a game entry if not already added
if SQLib.tableEmpty() == True:
print("You have not added any entries in the database! Add at least one entry:")
backend.addEntry()
def showMenuGetInput():
print("-"*50)
functionDictionary = {'v': "View the library", 'a': "Add a new entry", 'd': "Delete a entry",
's': "Search for something", 'u': "Update a existing entry", 'q': "quit"} # dictonary to store the menu entries
for i in functionDictionary:
print(i + ". ", functionDictionary[i])
menuChoice = input("Enter the function you wanna execute: ")
print("-"*50)
return menuChoice
userChoice = showMenuGetInput()
def execute_user_choice(userChoice):
match userChoice:
case 'v':
SQLib.show_all()
case 's':
backend.search()
case 'a':
backend.addEntry()
case 'd':
backend.DelRec()
case 'u':
backend.UpdateRec()
case '_':
print("invalid Input")
while userChoice != 'q':
execute_user_choice(userChoice)
userChoice = showMenuGetInput()
SQLib.closeDB()
print("Credits for this programme: Mr. Atul Verma, Codeacademy, Stackoverflow, GeeksforGeeks, Sagnik(for testing)")