added DataStore.createTask()
This commit is contained in:
parent
6574f4d4fd
commit
585d3d65e1
30
DataStore.py
30
DataStore.py
@ -95,4 +95,34 @@ WHERE id = ?
|
||||
for row in c:
|
||||
t = Task(row[0], row[1], row[2])
|
||||
c.close()
|
||||
self.conn.commit()
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user