utils.py 4.16 KB
Newer Older
alexjubs's avatar
parser    
alexjubs committed
1
from client_jubs.getattributes import courseInfo_attributes
alexjubs's avatar
alexjubs committed
2
3
4
5
from parser import *

options = [
	"insert-entry",
alexjubs's avatar
parser    
alexjubs committed
6
	"modify-row",
alexjubs's avatar
alexjubs committed
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
	"delete-row",
	"get-courses",
	"get-assessments",
	"get-vle",
	"get-students"
]

new_options = [
	"insert",
	"modify",
	"delete",
	"get"
]


# def get(cmd):
# 	pass
# 	base_table = input()

# 	list_of_shit_you_can_filter_on = list_of_shit_you_can_filter_on(base_table)
# 	list_of_user_filters = list()
# 	# branch on filtering
# 	for item in list_of_shit_you_can_filter_on:
# 		print(f"filtering on {item}")
# 		col_name = input("col name")
# 		operator = input("GT, LT, like, or ET")
# 		value = input("the attibute value")

# branching for get:
# 1. ask the base table
# 2. 


def handle_errors(command):
	if command[0] not in options:
		print(f"Error: command not in options. Options are:\n {options}")
		return True

	return False

def insert_entry(command):
	insert_entry_args = insert_entry_parser.parse_args(command[1:])

	# branch based on the table 
alexjubs's avatar
parser    
alexjubs committed
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
	if insert_entry_args.table == "courseInfo":
		pass

	elif insert_entry_args.table == "assessments":
		pass

	elif insert_entry_args.table == "studentAssessment":
		pass
	
	elif insert_entry_args.table == "courseOfferings":
		pass

	elif insert_entry_args.table == "studentInfo":
		student_id = input("student ID (primary key): ")
		highest_education = input("highest education: ")
		num_prev_attempts = input("")

	elif insert_entry_args.table == "region":
		pass

	elif insert_entry_args.table == "educationLevel":
		pass

	elif insert_entry_args.table == "vle":
		pass
alexjubs's avatar
alexjubs committed
76

alexjubs's avatar
parser    
alexjubs committed
77
78
79
80
81
82
83
84
	elif insert_entry_args.table == "studentVle":
		pass

	elif insert_entry_args.table == "studentRegistration":
		pass
	
	elif insert_entry_args.table == "studentUnregistration":
		pass
alexjubs's avatar
alexjubs committed
85
86
87
88
89
90


def modify_table(command):
	modify_table_args = modify_table_parser.parse_args(command[1:])

	# branch based on the table
alexjubs's avatar
parser    
alexjubs committed
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
	if modify_table_args.table == "courseInfo":
		attr = courseInfo_attributes()
		

		
		course_id = input("course_id (PK): ")
		course_code = input("new course_code: ")
		course_description = input("new course_description: ")

	elif modify_table_args.table == "assessments":
		

	elif modify_table_args.table == "studentAssessment":
		pass
	
	elif modify_table_args.table == "courseOfferings":
		pass

	elif modify_table_args.table == "studentInfo":
		student_id = input("student ID (primary key): ")
		highest_education = input("highest education: ")
		num_prev_attempts = input("")

	elif modify_table_args.table == "region":
		pass

	elif modify_table_args.table == "educationLevel":
		pass

	elif modify_table_args.table == "vle":
		pass

	elif modify_table_args.table == "studentVle":
		pass

	elif modify_table_args.table == "studentRegistration":
		pass
	
	elif modify_table_args.table == "studentUnregistration":
		pass
alexjubs's avatar
alexjubs committed
131
132
133
134
135

def delete_row(command):
	delete_row_args = delete_row_parser.parse_args(command[1:])

	# branch based on the table
alexjubs's avatar
parser    
alexjubs committed
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
	if delete_row_args.table == "courseInfo":
		pass

	elif delete_row_args.table == "assessments":
		pass

	elif delete_row_args.table == "studentAssessment":
		pass
	
	elif delete_row_args.table == "courseOfferings":
		pass

	elif delete_row_args.table == "studentInfo":
		student_id = input("student ID (primary key): ")
		highest_education = input("highest education: ")
		num_prev_attempts = input("")

	elif delete_row_args.table == "region":
		pass

	elif delete_row_args.table == "educationLevel":
		pass

	elif delete_row_args.table == "vle":
		pass

	elif delete_row_args.table == "studentVle":
		pass

	elif delete_row_args.table == "studentRegistration":
		pass
	
	elif delete_row_args.table == "studentUnregistration":
		pass
alexjubs's avatar
alexjubs committed
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193

def get_courses(command):
	get_courses_args = get_courses_parser.parse_args(command[1:])
	all = "all" in command

	# branch based on what to filter on

def get_assessments(command):
	get_assessments_args = get_assessments_parser.parse_args(command[1:])
	all = "all" in command

	# branch based on what to filter on

def get_vle(command):
	get_vle_args = get_vle_parser.parse_args(command[1:])
	all = "all" in command

	# branch based on what to filter on

def get_students(command):
	get_students_args = get_students_parser.parse_args(command[1:])
	all = "all" in command

	# branch based on what to filter on