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
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
+
cursor.execute("CREATE TABLE IF NOT EXISTS types (type_id INTEGER PRIMARY KEY, type TEXT UNIQUE)")
9
+
10
+
cursor.execute('SELECT * FROM types')
11
+
iflen(cursor.fetchall()) ==0:
12
+
count=0
13
+
whilecount!=5:
14
+
count+=1
15
+
ifcount==1:
16
+
values= (None, 'Chores')
17
+
elifcount==2:
18
+
values= (None, 'Homework')
19
+
elifcount==3:
20
+
values= (None, 'Work')
21
+
elifcount==4:
22
+
values= (None, 'Exercise')
23
+
elifcount==5:
24
+
values= (None, 'Other')
25
+
cursor.execute("INSERT INTO types VALUES (?, ?)", values)
26
+
connect.commit()
27
+
28
+
defget_choice(max, phrase, do_phrase=True):
29
+
choice=0
30
+
whilechoice>maxorchoice<1:
31
+
try:
32
+
ifdo_phrase:
33
+
print(phrase)
34
+
choice=int(input('-> '))
35
+
print()
36
+
ifchoice>maxorchoice<1:
37
+
print('Not a valid number.')
38
+
time.sleep(.5)
39
+
exceptValueError:
40
+
print('\nNot a valid number.')
41
+
time.sleep(.5)
42
+
returnchoice
43
+
44
+
defget_all():
45
+
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
+
returncursor.fetchall()
47
+
48
+
defget_tasks():
49
+
cursor.execute("SELECT task FROM tasks")
50
+
returncursor.fetchall()
51
+
52
+
defget_types():
53
+
cursor.execute("SELECT * FROM types")
54
+
returncursor.fetchall()
55
+
56
+
defget_value(data, new=False):
57
+
value=-1
58
+
whilevalue<0:
59
+
try:
60
+
ifdata=='hours':
61
+
value=float(input('\nTime to complete in hours: '))
0 commit comments