Commit d19d59da authored by alexjubs's avatar alexjubs
Browse files

filtering update

parent 84766994
......@@ -4,8 +4,8 @@ from parser import *
options_switchcase = {
"insert" : insert_base_func,
"modify" : modify_base_func,
"delete" : delete_base_func,
"get" : get_base_func
"delete-from" : delete_base_func,
"get-from" : get_base_func
}
if __name__ == "__main__":
......
......@@ -21,8 +21,9 @@ def handle_collecting_modify_args(attributes, new_row):
new_row[attributes[i]] = input(f"specify {attributes[i]} (blank space for no change): ")
return 0
def handle_filtering_on_table(attributes, filters):
def handle_filtering_on_table(attributes):
print(f"applying filters for {attributes}")
filters = list()
int_operators = ["=", ">", "<", ">=", "<=", "<>"]
string_operators = ["LIKE", "="]
bool_operators = ["="]
......@@ -55,11 +56,11 @@ def handle_filtering_on_table(attributes, filters):
value = input("Enter the filtering value (1 or 0): ")
while value not in {"0", "1"}:
value = input("Enter the filtering value (1 or 0): ")
filters[filtering_attribute] = {
filters.append({
"attribute" : filtering_attribute,
"value" : value,
"operator" : operator
}
})
should_filter = input(f"Would you like to apply another filter for any of `{attributes}`? \n 'y' or 'yes': ") in {"y", "yes"}
......@@ -89,7 +90,7 @@ def modify_base_func(command):
def delete_base_func(command):
delete_rows_args = delete_rows_parser.parse_args(command[1:])
filters = dict()
filters = list()
# branch based on the table
handle_filtering_on_table(
......@@ -101,7 +102,7 @@ def delete_base_func(command):
def get_base_func(command):
get_rows_args = get_rows_parser.parse_args(command[1:])
filters = dict()
filters = list()
# apply filters
handle_filtering_on_table(
......
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