Skip to content

Commit c5a8e3d

Browse files
authored
Merge pull request #1 from jakeard/work
added most of UI, view, add, and update tasks
2 parents f889261 + 3d558c2 commit c5a8e3d

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed

planner.db

8 KB
Binary file not shown.

planner.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import sqlite3 as sql
2+
3+
connect = sql.connect('planner.db')
4+
cursor = connect.cursor()
5+
6+
cursor.execute("CREATE TABLE IF NOT EXISTS tasks (type TEXT, task TEXT, time REAL)")
7+
8+
print('Welcome to your planner!')
9+
10+
choice = None
11+
while choice != 3:
12+
print('\nWhat would you like to do?')
13+
print('1). View Tasks')
14+
print('2). Edit Planner')
15+
print('3). Quit')
16+
try:
17+
choice = int(input('-> '))
18+
except ValueError:
19+
print('\nNot a valid number.')
20+
21+
if choice == 1:
22+
cursor.execute("SELECT * FROM tasks")
23+
print('\n{:<15} {:<15} {:<15}'.format('Type', 'Task', 'Time'))
24+
25+
for task in cursor.fetchall():
26+
print('{:<15} {:<15} {:<15}\n'.format(task[0], task[1], task[2]))
27+
28+
if choice == 2:
29+
print('\nWould you like to:')
30+
print('1). Add')
31+
print('2). Edit')
32+
print('3). Delete')
33+
print('4). Reset')
34+
print('5). Go back')
35+
try:
36+
choice = int(input('-> '))
37+
except ValueError:
38+
print('\nNot a valid number.')
39+
40+
if choice == 1:
41+
task = input('\nTask: ')
42+
type = input('Type of task: ')
43+
time = float(input('Time to complete in hours: '))
44+
values = (type, task, time)
45+
cursor.execute("INSERT INTO tasks VALUES (?, ?, ?)", values)
46+
connect.commit()
47+
48+
elif choice == 2:
49+
cursor.execute("SELECT * FROM tasks")
50+
tasks = cursor.fetchall()
51+
print('\nWhich number task would you like to edit? ')
52+
for i, task in enumerate(tasks):
53+
print(f'{i + 1}. {task[1]}')
54+
choice = int(input('-> '))
55+
task_name =tasks[choice - 1][1]
56+
print('\nWould you like to edit:')
57+
print('1). Task')
58+
print('2). Type')
59+
print('3). Time')
60+
try:
61+
choice = int(input('-> '))
62+
except ValueError:
63+
print('\nNot a valid number.')
64+
if choice == 1:
65+
task = input('\nTask: ')
66+
values = (task, task_name)
67+
cursor.execute("UPDATE tasks SET task = ? WHERE task = ?", values)
68+
connect.commit()
69+
elif choice == 2:
70+
type = input('Type of task: ')
71+
values = (type, task_name)
72+
cursor.execute("UPDATE tasks SET type = ? WHERE task = ?", values)
73+
connect.commit()
74+
elif choice == 3:
75+
choice = None
76+
time = float(input('Time to complete in hours: '))
77+
values = (time, task_name)
78+
cursor.execute("UPDATE tasks SET time = ? WHERE task = ?", values)
79+
connect.commit()
80+
else:
81+
print('Not a valid number.')
82+
83+
84+
85+
86+
87+
elif choice == 3:
88+
delete = int(input('\nWhich number item would you like to delete? '))
89+
choice = None
90+
elif choice == 4:
91+
verify = input('\nAre you sure you want to reset the planner? (y/n) ')
92+
elif choice == 5:
93+
pass
94+
else:
95+
print('Not a valid number.')
96+
97+
98+
99+
100+

sql.py

Whitespace-only changes.

0 commit comments

Comments
 (0)