You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: planner.py
+32-2
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,15 @@
1
1
importsqlite3assql
2
2
importtime
3
3
4
+
# create DB
4
5
connect=sql.connect('planner.db')
5
6
cursor=connect.cursor()
6
7
8
+
# create tables in DB
7
9
cursor.execute("CREATE TABLE IF NOT EXISTS tasks (task_id INTEGER PRIMARY KEY, task TEXT UNIQUE, time REAL, year TEXT, month TEXT, day TEXT, type_id INTEGER, FOREIGN KEY(type_id) REFERENCES types(type_id))")
8
10
cursor.execute("CREATE TABLE IF NOT EXISTS types (type_id INTEGER PRIMARY KEY, type TEXT UNIQUE)")
9
11
12
+
# insert types into the types table
10
13
cursor.execute('SELECT * FROM types')
11
14
iflen(cursor.fetchall()) ==0:
12
15
count=0
@@ -26,6 +29,7 @@
26
29
connect.commit()
27
30
28
31
defget_choice(max, phrase, do_phrase=True):
32
+
# gets the user's choice for the given amount of numbers
# returns all of the data needed to show all tasks and their types, due dates, and times
45
50
cursor.execute("SELECT ta.task, ty.type, (ta.month || '/' || ta.day || '/' || ta.year) AS date, ta.time FROM tasks ta JOIN types ty ON ta.type_id = ty.type_id ORDER BY ta.year, ta.month, ta.day, ta.time")
46
51
returncursor.fetchall()
47
52
48
53
defget_tasks():
54
+
# returns only the task names
49
55
cursor.execute("SELECT task FROM tasks")
50
56
returncursor.fetchall()
51
57
52
58
defget_types():
59
+
# returns only the type names
53
60
cursor.execute("SELECT * FROM types")
54
61
returncursor.fetchall()
55
62
56
63
defget_value(data, new=False):
64
+
# get's the value for the given variable (time or date)
57
65
value=-1
58
66
whilevalue<0:
59
67
try:
60
68
ifdata=='hours':
69
+
# get the amount of hours
61
70
value=float(input('\nTime to complete in hours: '))
0 commit comments