Commit 2f68d534 authored by alexjubs's avatar alexjubs
Browse files

welcome message

parent 049ddcbb
......@@ -8,10 +8,20 @@ options_switchcase = {
}
if __name__ == "__main__":
print(
'''
Welcome to our ECE 356 final project client!
insert - inserts an entry into the table
modify - modifies an entry in a table by primary key
delete - deletes a row (or mulitple rows) from the table
get - fetches a set of rows from a table in the DB
''')
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 {list(options_switchcase.keys())}")
continue
......
......@@ -18,48 +18,48 @@ from parser import *
# 1. ask the base table
# 2.
def handle_collecting_insert_args(attributes, new_column):
def handle_collecting_insert_args(attributes, new_row):
# 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
new_row[attributes[i]] = input(f"specify {attributes[i]} (this is a PK - it is required): ")
if new_row[attributes[i]] == '': return -1
continue
new_column[attributes[i]] = input(f"specify {attributes[i]} (blank space for none): ")
new_row[attributes[i]] = input(f"specify {attributes[i]} (blank space for none): ")
return 0
def handle_collecting_modify_args(attributes, new_column):
def handle_collecting_modify_args(attributes, new_row):
# 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
new_row[attributes[i]] = input(f"specify {attributes[i]} (this is a PK - it is required): ")
if new_row[attributes[i]] == '': return -1
continue
new_column[attributes[i]] = input(f"specify {attributes[i]} (blank space for no change): ")
new_row[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()
new_row = dict()
# branch based on the table
if handle_collecting_insert_args(
attributes=get_attributes_from_tablename[insert_entry_args.table],
new_column=new_column
new_row=new_row
) == -1: return
print(f"INSERTING column: \n {new_column} \n into table {insert_entry_args.table}")
print(f"INSERTING row: \n {new_row} \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()
new_row = dict()
# branch based on the table
if handle_collecting_modify_args(
attributes=get_attributes_from_tablename[modify_table_args.table],
new_column=new_column
new_row=new_row
) == -1: return
print(f"INSERTING column: \n {new_column} \n into table {modify_table_args.table}")
print(f"INSERTING row: \n {new_row} \n into table {modify_table_args.table}")
def delete_base_func(command):
......
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