forked from remm23/DMS-Group-Work
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
53 lines (48 loc) · 1.4 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
48
49
50
51
52
53
import os, database
os.system('powershell.exe cls')
active = True
prompt = ':>'
def help():
print()
print('\t\t--- Database Management System Commands ---')
print('delete <column> <data> <table>:\t\t\t\t\t\t\tDelete a row from a table')
print('find <data> <column> <table>:\t\t\t\t\t\t\tFilter out rows to find user')
print('help:\t\t\t\t\t\t\t\t\t\tShow help menu')
print('quit:\t\t\t\t\t\t\t\t\t\tExit the system')
print('update <column1> <data> <table> <column2> <data>:\t\t\t\tUpdate a row in a table')
print('showall <table>:\t\t\t\t\t\t\t\tShow all rows in a table')
print()
print('\t\t--- PARTSWORLD DMS ---')
print('\ttype \'help\' to show a list of commands')
while (active):
line = input(prompt)
if not line:
pass
elif line.lower() == 'quit':
active = False
elif 'delete' in line:
args = line.split(' ')
## delete the <id> <x> from <table>
database.delete(args[1],args[2],args[3])
elif 'find' in line:
args = line.split(' ')
try:
database.find(args[1],args[2],args[3])
except:
print("Invalid query")
elif line == 'help':
help()
elif 'showall' in line:
try:
database.showall(line[8:])
except:
print("Invalid query")
elif 'update' in line:
args = line.split(' ')
try:
## update <col> to <x> in <table> where <col2> = <y>
database.update(args[1], args[2], args[3], args[4], args[5])
except:
print('Invalid query')
else:
print('invalid input: ' + line)