From 684834806ef6f00467a4371d627cbf39bda69a32 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 1 Jan 2011 23:06:10 -0500 Subject: [PATCH] updated database schema again for dates and hours --- DataStore.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/DataStore.py b/DataStore.py index fd20af1..f3f05e2 100644 --- a/DataStore.py +++ b/DataStore.py @@ -3,10 +3,10 @@ import sqlite3 import os class DataStore: - def __init__(self, timedbfile): - if not os.path.exists(timedbfile): - self.createdb(timedbfile) - self.conn = sqlite3.connect(timedbfile) + def __init__(self, dbfile): + if not os.path.exists(dbfile): + self.createdb(dbfile) + self.conn = sqlite3.connect(dbfile) def __del__(self): self.conn.close() @@ -24,15 +24,17 @@ CREATE TABLE tasks ( )''') c.execute(''' CREATE TABLE entries ( - date INTEGER PRIMARY KEY, + date TEXT, taskid INTEGER, - hours REAL, + seconds INTEGER, + PRIMARY KEY (date, taskid), FOREIGN KEY (taskid) REFERENCES tasks(id) )''') c.execute(''' CREATE TABLE history ( id INTEGER PRIMARY KEY, taskid INTEGER, + datetime TEXT, FOREIGN KEY (taskid) REFERENCES tasks(id) )''') conn.commit()