added DataStore.getCurrentTask() and TaskRef class
This commit is contained in:
parent
e6d8d36aeb
commit
855068c43f
23
DataStore.py
23
DataStore.py
@ -1,6 +1,14 @@
|
||||
|
||||
import sqlite3
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
HISTORY_DT_FMT = '%Y-%m-%d %H:%M:%S'
|
||||
|
||||
class TaskRef:
|
||||
def __init__(self, taskid, dt):
|
||||
self.taskid = taskid
|
||||
self.dt = dt
|
||||
|
||||
class DataStore:
|
||||
def __init__(self, dbfile):
|
||||
@ -41,3 +49,18 @@ CREATE TABLE history (
|
||||
c.close()
|
||||
conn.close()
|
||||
|
||||
def getCurrentTask(self):
|
||||
c = self.conn.cursor()
|
||||
c.execute('''
|
||||
SELECT taskid, datetime
|
||||
FROM history
|
||||
WHERE id = 0
|
||||
''')
|
||||
ct = None
|
||||
for row in c:
|
||||
taskid = row[0]
|
||||
dt = datetime.strptime(row[1], HISTORY_DT_FMT)
|
||||
ct = TaskRef(taskid, dt)
|
||||
c.close()
|
||||
self.conn.commit()
|
||||
return ct
|
||||
|
Loading…
x
Reference in New Issue
Block a user