From 9ea1ab90b4705ef4d5ce37ded36a214f276c0a18 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 31 Mar 2013 18:32:13 +0200 Subject: add and delete accounts, db will be resetted --- module/database/AccountDatabase.py | 8 ++++++-- module/database/DatabaseBackend.py | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'module/database') diff --git a/module/database/AccountDatabase.py b/module/database/AccountDatabase.py index 1602451fa..518674951 100644 --- a/module/database/AccountDatabase.py +++ b/module/database/AccountDatabase.py @@ -3,8 +3,8 @@ from module.database import queue, async from module.database import DatabaseBackend -class AccountMethods: +class AccountMethods: @queue def loadAccounts(db): db.c.execute('SELECT plugin, loginname, activated, password, options FROM accounts;') @@ -12,10 +12,14 @@ class AccountMethods: @async def saveAccounts(db, data): - db.c.executemany('INSERT INTO accounts(plugin, loginname, activated, password, options) VALUES(?,?,?,?,?)', data) + # TODO: owner, shared + + db.c.executemany( + 'INSERT INTO accounts(plugin, loginname, activated, password, options) VALUES(?,?,?,?,?)', data) @async def removeAccount(db, plugin, loginname): db.c.execute('DELETE FROM accounts WHERE plugin=? AND loginname=?', (plugin, loginname)) + DatabaseBackend.registerSub(AccountMethods) \ No newline at end of file diff --git a/module/database/DatabaseBackend.py b/module/database/DatabaseBackend.py index e77fc0966..54d1c54bb 100644 --- a/module/database/DatabaseBackend.py +++ b/module/database/DatabaseBackend.py @@ -30,7 +30,7 @@ except: import sqlite3 DB = None -DB_VERSION = 5 +DB_VERSION = 6 def set_DB(db): global DB @@ -162,9 +162,9 @@ class DatabaseBackend(Thread): self.conn.close() try: - self.manager.core.log.warning(_("File database was deleted due to incompatible version.")) + self.manager.core.log.warning(_("Database was deleted due to incompatible version.")) except: - print "File database was deleted due to incompatible version." + print "Database was deleted due to incompatible version." remove(self.VERSION_FILE) move(self.DB_FILE, self.DB_FILE + ".backup") @@ -225,7 +225,7 @@ class DatabaseBackend(Thread): #--convert scripts start - def _convertV5(self): + def _convertV6(self): return False #--convert scripts end @@ -364,7 +364,7 @@ class DatabaseBackend(Thread): 'CREATE TABLE IF NOT EXISTS "accounts" (' '"plugin" TEXT NOT NULL, ' '"loginname" TEXT NOT NULL, ' - '"owner", INTEGER NOT NULL, ' + '"owner" INTEGER NOT NULL DEFAULT -1, ' '"activated" INTEGER DEFAULT 1, ' '"password" TEXT DEFAULT "", ' '"shared" INTEGER DEFAULT 0, ' -- cgit v1.2.3