summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
Diffstat (limited to 'storage')
-rw-r--r--storage/sqlite.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/storage/sqlite.py b/storage/sqlite.py
index 5b21054..09e55fc 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.1'
+ dbVersion = '0.2'
def __init__(self):
self.con = sqliteBackend.connect(self.getConfigDir() + '/data.sqlite')
@@ -22,7 +22,7 @@ class sqlite(storageBase):
version = self.cur.execute("select value from control where setting='db-version'").fetchone()
if (sqlite.dbVersion,) != version:
# TODO: update not init
- self.init_db()
+ self.update_db(version)
@@ -47,6 +47,17 @@ class sqlite(storageBase):
self.cur.execute("insert into control (setting, value) VALUES ('db-version', ?)", (sqlite.dbVersion,))
self.con.commit()
+ def update_db(self, updateFrom):
+ print 'updating todo table...'
+ if updateFrom == '0.1':
+ self.cur.execute('''alter table todo
+ add desc BLOB''')
+ self.con.commit()
+ updateFrom = '0.2'
+
+ self.cur.execute("update control set value = ? where setting = 'db-version'", (sqlite.dbVersion,))
+ self.con.commit()
+
def __del__(self):
self.con.close()
@@ -60,11 +71,11 @@ class sqlite(storageBase):
def notifyChange(self, sender):
if sender.getId() >= 0:
- self.cur.execute('update todo set title=?, createdAt=?, priority=? where id=?',
- (sender.getTitle(), sender.getCreatedAt(), sender.getPriority(), sender.getId()))
+ self.cur.execute('update todo set title=?, createdAt=?, priority=?, desc=? where id=?',
+ (sender.getTitle(), sender.getCreatedAt(), sender.getPriority(), sender.getId(), sender.getDescription()))
self.con.commit()
else:
- self.cur.execute('insert into todo (title, createdAt, priority) VALUES (?, ?, ?)',
- (sender.getTitle(), sender.getCreatedAt(), sender.getPriority()))
+ self.cur.execute('insert into todo (title, createdAt, priority, desc) VALUES (?, ?, ?, ?)',
+ (sender.getTitle(), sender.getCreatedAt(), sender.getPriority(), sender.getDescription()))
self.con.commit()
sender.setId(self.cur.execute('select last_insert_rowid()').fetchone()[0])