writes to database

This commit is contained in:
Mikayla Dobson
2022-04-06 13:11:54 -05:00
parent bb2807e5fe
commit d49aa5da5b
2 changed files with 36 additions and 6 deletions

View File

@@ -25,8 +25,9 @@ cur.executemany("INSERT INTO TIMESTAMPS VALUES (?, ?, ?, ?, ?)", timestamp_list)
# 3) Calculate total hours for the week # 3) Calculate total hours for the week
# 4) Calculate complete sum of hours # 4) Calculate complete sum of hours
def create_new_stamp(): def create_new_stamp(timestamp, name, purpose):
current_time = '' to_insert = (999, timestamp, 'null', name, purpose)
cur.execute("INSERT INTO TIMESTAMPS VALUES (?, ?, ?, ?, ?)", to_insert)
def get_all_stamps(): def get_all_stamps():
return cur.execute("SELECT * FROM TIMESTAMPS;") return cur.execute("SELECT * FROM TIMESTAMPS;")

View File

@@ -1,5 +1,4 @@
from database import * from database import *
from datetime import datetime
user_prompt = """ user_prompt = """
Welcome to the personal time stamp program. Welcome to the personal time stamp program.
@@ -15,9 +14,39 @@ Please choose from the following options:
# Inner functions detailed below: # Inner functions detailed below:
def handle_first_option(): def handle_first_option():
current_time = datetime.now() time_of_stamp = datetime.now()
print(f'Current time: {str(current_time)}') in_out = input("Punching in or out? i/o \n")
print("Creating a new timestamp. Enter the following details:")
if in_out == 'i':
print("Creating new timestamp and punching in!")
print("Please enter the following details:")
name = input("Your name: ")
purpose = input("Current task: ")
print("\nPlease confirm your details:")
confirmation = input(f'{name} clocking in at {time_of_stamp} for {purpose}. Confirm? y/n ')
if confirmation == 'n':
handle_first_option()
elif confirmation == 'y':
create_new_stamp(time_of_stamp, name, purpose)
new_selection = input("Data entered. Make another selection? y/n ")
if new_selection == 'y':
parse_input()
elif new_selection == 'n':
pass
else:
print("Invalid input. Exiting...")
pass
else:
print("Invalid input.")
handle_first_option()
elif in_out == 'o':
print("Punching out.")
else:
print("Invalid input. Please try again:")
handle_first_option()
def handle_second_option(): def handle_second_option():
limit_results = input("Returning all timestamps. Limit results? y/n \n") limit_results = input("Returning all timestamps. Limit results? y/n \n")