diff --git a/data.db b/data.db index 49a92c9..8642242 100644 Binary files a/data.db and b/data.db differ diff --git a/database.py b/database.py index 1596cbb..b2dc71b 100644 --- a/database.py +++ b/database.py @@ -12,12 +12,13 @@ cur.execute("CREATE TABLE IF NOT EXISTS USERS (id INTEGER PRIMARY KEY, name STRI # declare and insert some initial values timestamp_list = [ - (1, '1pm', 'null', 'Mikayla', 'work on project'), - (2, '9pm', '11pm', 'not Mikayla', 'work on project'), - (3, '8am', '5pm', 'someone else', 'debugging') + ('Mikayla', 'work on project'), + ('not Mikayla', 'work on project'), + ('someone else', 'debugging') ] -cur.executemany("INSERT INTO TIMESTAMPS VALUES (?, ?, ?, ?, ?)", timestamp_list) +cur.executemany("INSERT INTO TIMESTAMPS (name, purpose) VALUES (?, ?)", timestamp_list) +con.commit() # Functions to define: # 1) Select all timestamps @@ -26,8 +27,9 @@ cur.executemany("INSERT INTO TIMESTAMPS VALUES (?, ?, ?, ?, ?)", timestamp_list) # 4) Calculate complete sum of hours def create_new_stamp(timestamp, name, purpose): - to_insert = (999, timestamp, 'null', name, purpose) - cur.execute("INSERT INTO TIMESTAMPS VALUES (?, ?, ?, ?, ?)", to_insert) + to_insert = (timestamp, name, purpose) + cur.execute("INSERT INTO TIMESTAMPS (time_in, name, purpose) VALUES (?, ?, ?)", to_insert) + con.commit() def get_all_stamps(): return cur.execute("SELECT * FROM TIMESTAMPS;") @@ -56,3 +58,7 @@ def get_weekly_hours(): def get_all_hours(): pass + + +def delete_all_rows(): + cur.executemany("DELETE * FROM TIMESTAMPS;") \ No newline at end of file diff --git a/db_util/database.pyc b/database.pyc similarity index 100% rename from db_util/database.pyc rename to database.pyc diff --git a/db_util/data.db b/db_util/data.db deleted file mode 100644 index 49a92c9..0000000 Binary files a/db_util/data.db and /dev/null differ diff --git a/user_input.py b/user_input.py index c65292a..697066e 100644 --- a/user_input.py +++ b/user_input.py @@ -10,6 +10,7 @@ Please choose from the following options: 3) Find a timestamp by date range 4) Calculate total hours for the week 5) Calculate complete sum of hours + """ # Inner functions detailed below: @@ -100,6 +101,33 @@ def handle_second_option(): def handle_third_option(): pass +def __admin__(): + print("ADMIN PORTAL") + print("Choose from additional actions below:") + print(""" + 1) Delete all rows from table (table and schema will persist) + 2) Drop table (database will reinitialize on next render) + 3) Backup data from SQLite file. + + Take care, some actions will permanently delete all data.\n + """) + admin_prompt = input("Your response: ") + + if int(admin_prompt) == 1: + print("Deleting all rows...") + delete_all_rows() + print("All rows deleted. Returning...") + parse_input() + elif int(admin_prompt) == 2: + print("Drop table. Confirm?") + elif int(admin_prompt) == 3: + print("Back up all SQLite data.") + else: + print("Invalid input.") + + + +# Dialogue tree for top-level path handling def parse_input(): print(user_prompt) @@ -130,6 +158,8 @@ def parse_input(): pass elif response == 4: pass + elif response == 871: + __admin__() else: print("Please provide a valid selection.") parse_input() \ No newline at end of file