-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinsert.py
More file actions
91 lines (71 loc) · 2.73 KB
/
insert.py
File metadata and controls
91 lines (71 loc) · 2.73 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import MiniWorld
import subprocess as sp
import colours
def a():
# Takes region details as input
id = input("Enter Region ID: ")
rname = input("Enter Region Name: ")
oname = input("Enter Organisation Name: ")
mgrid = input("Enter Region Manager ID: ")
query = f"INSERT INTO Region VALUES ('{id}','{rname}','{oname}','{mgrid}');"
if MiniWorld.executeQuery(query) == 1:
print(f"{colours.bcolors.OKGREEN}Inserted Into Database{colours.bcolors.ENDC}")
print("")
return
def b():
# Takes Money Front details as input
fname = input("Enter Front Name: ")
oname = input("Enter Organisation Name: ")
accid = input("Enter Accountant ID: ")
amount = float(input("Enter Amount Laundered: "))
query = f"INSERT INTO Money_Front VALUES ('{fname}','{oname}','{accid}','{amount}');"
if MiniWorld.executeQuery(query) == 1:
print(f"{colours.bcolors.OKGREEN}Inserted Into Database{colours.bcolors.ENDC}")
print("")
return
def c():
# Takes Employee details as input
eid = input("Enter Employee ID: ")
oname = input("Enter Organisation Name: ")
empType = input("Enter Employee Type: ")
sDate = input("Enter Start Date(YYYY-MM-DD): ")
eDate = input("Enter End Date(YYYY-MM-DD/NA): ")
rid = input("Enter Region ID: ")
fname = input("Enter First Name: ")
lname = input("Enter Last Name: ")
dob = input ("Enter Date of Birth(YYYY-MM-DD): ")
sal = float(input("Enter Salary: "))
if eDate.upper() == 'NA':
eDate = "9999-12-31"
query = f"INSERT INTO Employee VALUES ('{eid}','{oname}','{empType}','{sDate}','{eDate}','{rid}', '{fname}','{lname}','{dob}','{sal}');"
if MiniWorld.executeQuery(query) == 1:
print(f"{colours.bcolors.OKGREEN}Inserted Into Database{colours.bcolors.ENDC}")
print("")
return
def insert():
while(1):
tmp = sp.call('clear', shell=True)
print("Choose an operation:")
print(f"{colours.bcolors.OKCYAN}")
print("1. Region")
print("2. Money Front")
print("3. Employee")
print(f"{colours.bcolors.ENDC}{colours.bcolors.WARNING}")
print("4. Back")
print("5. Exit")
print(f"{colours.bcolors.ENDC}")
ch = input("Enter choice: ").lower()
tmp = sp.call('clear', shell = True)
if ch == '1' or ch == 'region':
a()
elif ch == '2' or ch == 'money front':
b()
elif ch == '3' or ch == 'employee':
c()
elif ch == '4' or ch == 'back':
return
elif ch == '5' or ch == 'exit':
exit()
else:
print(f"{colours.bcolors.RED}Invalid Option{colours.bcolors.ENDC}")
input("Enter any key to continue: ")