diff options
Diffstat (limited to 'storage/sqlite.py')
-rw-r--r-- | storage/sqlite.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/storage/sqlite.py b/storage/sqlite.py index bfdae42..7a8e1d8 100644 --- a/storage/sqlite.py +++ b/storage/sqlite.py @@ -6,7 +6,7 @@ from item import item from pysqlite2 import dbapi2 as sqliteBackend class sqlite(storageBase): - dbVersion = '0.3' + dbVersion = '0.4' def __init__(self): self.con = sqliteBackend.connect(self.getConfigDir() + '/data.sqlite') @@ -34,7 +34,9 @@ class sqlite(storageBase): title TEXT(255), createdAt INTEGER, priority INTEGER, - desc BLOB + desc BLOB, + completed INTEGER(1) DEFAULT (0), + removed INTEGER(1) DEFAULT (0) )''') self.cur.execute('drop table if exists control') @@ -61,6 +63,12 @@ class sqlite(storageBase): self.con.commit() updateFrom = ('0.3',) + if updateFrom == ('0.3',): + self.cur.execute('''alter table todo + add removed INTEGER(1) DEFAULT (0)''') + self.con.commit() + updateFrom = ('0.4',) + self.cur.execute("update control set value = ? where setting = 'db-version'", updateFrom) self.con.commit() @@ -69,7 +77,7 @@ class sqlite(storageBase): def load(self): items = itemList(self) - todos = self.cur.execute('select * from todo').fetchall() + todos = self.cur.execute('select * from todo where removed=0').fetchall() for todo in todos: items += item(row=list(todo)) @@ -77,11 +85,13 @@ class sqlite(storageBase): def notifyChange(self, sender): if sender.getId() >= 0: - self.cur.execute('update todo set title=?, createdAt=?, priority=?, desc=?, completed=? where id=?', - (sender.getTitle(), sender.getCreatedAt(), sender.getPriority(), sender.getDescription(), sender.getCompleted(), sender.getId())) + self.cur.execute('update todo set title=?, createdAt=?, priority=?, desc=?, completed=?, removed=? where id=?', + (sender.getTitle(), sender.getCreatedAt(), sender.getPriority(), + sender.getDescription(), sender.getCompleted(), sender.getRemoved(), sender.getId())) self.con.commit() else: - self.cur.execute('insert into todo (title, createdAt, priority, desc, completed) VALUES (?, ?, ?, ?, ?)', - (sender.getTitle(), sender.getCreatedAt(), sender.getPriority(), sender.getDescription(), sender.getCompleted())) + self.cur.execute('insert into todo (title, createdAt, priority, desc, completed, removed) VALUES (?, ?, ?, ?, ?, ?)', + (sender.getTitle(), sender.getCreatedAt(), sender.getPriority(), + sender.getDescription(), sender.getCompleted(), sender.getRemoved())) self.con.commit() sender.setId(self.cur.execute('select last_insert_rowid()').fetchone()[0]) |