summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2009-04-23 06:02:37 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2009-04-23 06:02:37 +0200
commit570ca6350777acc69429300bea4cc8f8eb97267e (patch)
treea142a5e1089b24d135e55f88f3d86acce5ff617e /storage
parentab9077633a539229533d03f56c627be9e88a7865 (diff)
downloadtodolist-570ca6350777acc69429300bea4cc8f8eb97267e.tar.gz
todolist-570ca6350777acc69429300bea4cc8f8eb97267e.tar.xz
todolist-570ca6350777acc69429300bea4cc8f8eb97267e.zip
gui extended, database layout 0.2
sortable and reorderable listview in gui db-version 0.2 with description field (BLOB
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])