working on user prompt

This commit is contained in:
Mikayla Dobson
2022-04-06 11:52:49 -05:00
parent 7632e72ef5
commit 1b804314da
2 changed files with 68 additions and 24 deletions

View File

@@ -1,5 +1,4 @@
import sqlite3 import sqlite3
from typing import ParamSpecArgs
from user_input import * from user_input import *
# establish a connection to a .db file and create a cursor object # establish a connection to a .db file and create a cursor object
@@ -19,26 +18,6 @@ timestamp_list = [
cur.executemany("INSERT INTO TIMESTAMPS VALUES (?, ?, ?, ?, ?)", timestamp_list) cur.executemany("INSERT INTO TIMESTAMPS VALUES (?, ?, ?, ?, ?)", timestamp_list)
"""
# The below logic for testing initial values are inserted,
# are able to be queried,
# and are accurately represented in the table.
# query table below:
table_rows = []
for row in cur.execute("SELECT * FROM TIMESTAMPS;"):
# print each result
print(row)
# store each result individually in the list above
table_rows.append(row)
# find COUNT(*) for the table
print(len(table_rows))
"""
# Functions to define: # Functions to define:
# 1) Select all timestamps # 1) Select all timestamps
# 2) Find a timestamp by date range # 2) Find a timestamp by date range
@@ -46,7 +25,19 @@ print(len(table_rows))
# 4) Calculate complete sum of hours # 4) Calculate complete sum of hours
def get_all_stamps(): def get_all_stamps():
pass 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)
def get_table_length():
table_rows = []
for row in cur.execute("SELECT * FROM TIMESTAMPS;"):
table_rows.append(row)
return len(table_rows)
def get_stamp_by_date(): def get_stamp_by_date():
pass pass

View File

@@ -1,16 +1,69 @@
from database import *
user_prompt = """ user_prompt = """
Welcome to the personal time stamp program. Welcome to the personal time stamp program.
This program is intended to help you keep track of your work hours on personal projects. This program is intended to help you keep track of your work hours on personal projects.
Please choose from the following options: Please choose from the following options:
1) Select all timestamps 1) Select all timestamps (option: limit number of results)
2) Find a timestamp by date range 2) Find a timestamp by date range
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 handle_first_option():
limit_results = input("Returning all timestamps. Limit results? y/n \n")
if limit_results == 'n':
output = get_all_stamps()
for row in output:
print(row)
elif limit_results == 'y':
def find_row_limit():
user_limit = input("How many rows? \n")
table_length = get_table_length()
try:
user_limit = int(user_limit)
except ValueError:
print("Please provide an integer.")
find_row_limit()
except:
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...')
find_row_limit()
elif limit_results != 'y' or limit_results != 'n':
print("Please provide a valid selection.")
handle_first_option()
def parse_input(): def parse_input():
print(user_prompt) print(user_prompt)
response = input("Enter your selection: ") response = input("Enter your selection: ")
print(f'You selected {response}. Working...') try:
response = int(response)
except ValueError:
print("Please provide an integer.")
parse_input()
except:
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:
pass
elif response == 3:
pass
elif response == 4:
pass
else:
pass