Commit 049ddcbb authored by alexjubs's avatar alexjubs
Browse files

modify & insert complete

parent 25a2e93f
......@@ -10,16 +10,15 @@ options_switchcase = {
if __name__ == "__main__":
while True:
command = input("Command: ").split()
if len(command) == 0: continue
if command[0] not in options_switchcase:
print(f"Error: command not in options. Options are:\n {options_switchcase.keys()}")
print(f"Error: command not in options. Options are:\n {list(options_switchcase.keys())}")
continue
if command[0] == "exit":
exit("Terminating...")
# pick the appropirate function given command[0]
options_switchcase(
options_switchcase[command[0]](command)
)
options_switchcase[command[0]](command)
\ No newline at end of file
from get_attributes import *
from parser import *
options = [
"insert",
"modify",
"delete",
"get"
]
# def get(cmd):
# pass
# base_table = input()
......@@ -30,127 +23,49 @@ def handle_collecting_insert_args(attributes, new_column):
for i in range(len(attributes)):
if i == 0:
new_column[attributes[i]] = input(f"specify {attributes[i]} (this is a PK - it is required): ")
if new_column[attributes[i]] == '': return -1
continue
new_column[attributes[i]] = input(f"specify {attributes[i]} (blank space for none): ")
return 0
def handle_collecting_modify_args(attributes, new_column):
# the first element in attributes is the PK
for i in range(len(attributes)):
if i == 0:
new_column[attributes[i]] = input(f"specify {attributes[i]} (this is a PK - it is required): ")
if new_column[attributes[i]] == '': return -1
continue
new_column[attributes[i]] = input(f"specify {attributes[i]} (blank space for no change): ")
return 0
def insert_base_func(command):
insert_entry_args = insert_entry_parser.parse_args(command[1:])
new_column = dict()
# branch based on the table
handle_collecting_insert_args(
if handle_collecting_insert_args(
attributes=get_attributes_from_tablename[insert_entry_args.table],
new_column=new_column
)
) == -1: return
print(f"INSERTING column: \n {new_column} \n into table {insert_entry_args.table}")
def modify_base_func(command):
modify_table_args = modify_table_parser.parse_args(command[1:])
new_column = dict()
# branch based on the table
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":
pass
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
# branch based on the table
if handle_collecting_modify_args(
attributes=get_attributes_from_tablename[modify_table_args.table],
new_column=new_column
) == -1: return
print(f"INSERTING column: \n {new_column} \n into table {modify_table_args.table}")
elif modify_table_args.table == "studentRegistration":
pass
elif modify_table_args.table == "studentUnregistration":
pass
def delete_base_func(command):
delete_row_args = delete_row_parser.parse_args(command[1:])
# branch based on the table
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
def get_base_func(command):
pass
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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment