From 1880b60602cd019461e207c6de0bc3d7489a3d6c Mon Sep 17 00:00:00 2001 From: Mikayla Dobson <93477693+innocuous-symmetry@users.noreply.github.com> Date: Wed, 6 Apr 2022 12:06:14 -0500 Subject: [PATCH] first option detailed --- database.py | 12 ++++++++++-- main.py | 2 +- user_input.py | 44 +++++++++++++++++++++++++++++++++++++++----- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/database.py b/database.py index 7d4ebef..a82931b 100644 --- a/database.py +++ b/database.py @@ -27,10 +27,17 @@ cur.executemany("INSERT INTO TIMESTAMPS VALUES (?, ?, ?, ?, ?)", timestamp_list) def get_all_stamps(): return cur.execute("SELECT * FROM TIMESTAMPS;") + def get_number_of_stamps(input): table_rows = [] - for row in cur.execute("SELECT * FROM TIMESTAMPS;"): - table_rows.append(row) + table_values = cur.execute("SELECT * FROM TIMESTAMPS;") + + iterator = 0 + while (iterator < input): + table_rows.append(table_values[iterator]) + iterator += 1 + + return table_rows def get_table_length(): @@ -39,6 +46,7 @@ def get_table_length(): table_rows.append(row) return len(table_rows) + def get_stamp_by_date(): pass diff --git a/main.py b/main.py index 589a506..ac685fb 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,4 @@ from user_input import * from database import * -parse_input() \ No newline at end of file +parse_input() diff --git a/user_input.py b/user_input.py index d0eae35..70351bc 100644 --- a/user_input.py +++ b/user_input.py @@ -22,6 +22,7 @@ def handle_first_option(): def find_row_limit(): user_limit = input("How many rows? \n") table_length = get_table_length() + try: user_limit = int(user_limit) except ValueError: @@ -31,16 +32,44 @@ def handle_first_option(): print("An unknown error occurred. Please try again.") find_row_limit() - if type(user_limit) is int: - print(f'Returning first {user_limit} rows of data...') - - + if (user_limit > table_length): + print("Provided input is larger than available rows in table.") + print("Printing all rows...") + output = get_all_stamps() + for row in output: + print(row) + else: + table_rows = get_number_of_stamps(user_limit) + for row in table_rows: + print(row) + + another_selection = input("Make another selection? y/n \n") + + if another_selection == 'y': + parse_input() + elif another_selection == 'n': + pass + else: + print("Make another selection:") + parse_input() + find_row_limit() elif limit_results != 'y' or limit_results != 'n': print("Please provide a valid selection.") handle_first_option() + +def handle_second_option(): + pass + +def handle_third_option(): + pass + +def handle_fourth_option(): + pass + + def parse_input(): print(user_prompt) response = input("Enter your selection: ") @@ -54,9 +83,13 @@ def parse_input(): print("Please provide a valid input.") parse_input() + + if type(response) == int: print(f'You selected {response}. Working...') + + if response == 1: handle_first_option() elif response == 2: @@ -66,4 +99,5 @@ def parse_input(): elif response == 4: pass else: - pass \ No newline at end of file + print("Please provide a valid selection.") + parse_input() \ No newline at end of file