added DataStore.createTask()

This commit is contained in:
Josh Holtrop 2011-01-02 14:23:43 -05:00
parent 6574f4d4fd
commit 585d3d65e1

View File

@ -95,4 +95,34 @@ WHERE id = ?
for row in c: for row in c:
t = Task(row[0], row[1], row[2]) t = Task(row[0], row[1], row[2])
c.close() c.close()
self.conn.commit()
return t return t
def createTask(self, name, longname, parentid):
c = self.conn.cursor()
if parentid is not None and parentid != '':
c.execute('''
SELECT *
FROM tasks
WHERE id = ?
''', (parentid,))
found = False
for row in c:
found = True
if not found:
return 0
c.execute('''
SELECT MAX(id)
FROM tasks
''')
nextid = 1
for row in c:
if row[0] is not None:
nextid = row[0] + 1
c.execute('''
INSERT INTO tasks
VALUES (?, ?, ?, ?)
''', (nextid, name, longname, parentid))
c.close()
self.conn.commit()
return nextid