-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.py
More file actions
109 lines (94 loc) · 3.19 KB
/
tasks.py
File metadata and controls
109 lines (94 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#tasks app
import sqlite3
import time
dot="new tasks?(ntask), completed a task?(comp), print tasks(ptask),delete a task?(d), view not completed tasks(nc), view completed tasks(c), add timer for task(t)???"
dotdot = raw_input(dot);
task=[];
conn=sqlite3.connect('task.db');
c = conn.cursor();
c.execute('''CREATE TABLE IF NOT EXISTS tasks (category text, task text, completed text(1), time decimal(6,2))''')
conn.commit()
while dotdot != 'stop':
if dotdot=='new task' or dotdot=='ntask' or dotdot=='n':
catn=raw_input('What is the category of you task?');
taskn=raw_input('What is your task?');
compn='n';
tasktime=0;
c.execute('INSERT INTO tasks VALUES (?,?,?,?)', (catn,taskn,compn,tasktime));
conn.commit();
dotdot = raw_input(dot);
elif dotdot=='count':
print len(task);
dotdot = raw_input(dot);
elif dotdot=='ptask' or dotdot=='print tasks' or dotdot=='p':
# for item in task:
# print item;
for row in c.execute('select rowid, category, task, completed, tasktime from tasks'):
print str(row)
conn.commit();
dotdot = raw_input(dot);
elif dotdot=='comptask'or dotdot=='c':
for row in c.execute('select rowid, category, task, from tasks where completed="y"'):
print str(row)
conn.commit();
dotdot = raw_input(dot);
elif dotdot=='nocomptask' or dotdot=='nc':
for row in c.execute('select rowid, category, task, timer from tasks where completed="n"'):
print str(row)
conn.commit();
dotdot = raw_input(dot);
elif dotdot=='completed' or dotdot=='comp':
compnum=raw_input("what task number was compeleted");
compquery="UPDATE tasks SET completed='y' WHERE rowid=%s" %compnum
c.execute(compquery);
conn.commit();
dotdot=raw_input(dot);
elif dotdot=='d':
delete=raw_input("which row id would you like to delete?");
dquery = "delete from tasks where rowid= %s" % delete
#c.execute('DELETE FROM tasks WHERE rowid=', (delete,));
c.execute(dquery);
conn.commit();
dotdot = raw_input(dot);
elif dotdot=='t':
tin=raw_input("which row id would you like to add a timer for the task?")
prompt=raw_input("would you like an hour prompt(1) or start a timer(2) or end a timer(3)?")
if prompt=='1':
stim=time.time()
print "timer started"
etim = time.time()
if etim - stim == 3600:
print "Hour has passed"
elif prompt=='2':
stim2=time.time()
print "timer started"
elif prompt=='3':
etim2=time.time()
print "Timer Ended"
dtim=(etim2 - stim2)/60.0
tquery="UPDATE tasks SET timer=%s WHERE rowid=%s" %(dtim, tin)
c.execute(tquery);
conn.commit();
else:
print "try again"
dotdot = raw_input(dot);
else:
print "what? try again"
dotdot = raw_input(dot);
x=0
#var_string = '?'
#var_string = ', '.join('?' * len(task))
#print var_string
#turns it into (?,?,?,?,?), must use the ? to prevent #sqlattacks
#query_string= 'INSERT INTO tasks VALUES(%s);' % var_string
#print query_string
#c.execute(query_string, (task,))
#for i in task:
# c.execute(query_string, (task[x],))
#normal syntax is c.executemany('INSERT INTO stocks VALUES #(?,?,?,?,?)', purchases) but query_string replaces insert #into, task replaces purchases
# conn.commit()
# x=x+1
for row in c.execute('select * from tasks'):
print row
conn.commit()
c.close()