diff options
author | 2013-03-31 18:32:13 +0200 | |
---|---|---|
committer | 2013-03-31 18:32:13 +0200 | |
commit | 9ea1ab90b4705ef4d5ce37ded36a214f276c0a18 (patch) | |
tree | 995539a44a25c54344639d5ade7aa3e48624ed97 /module/database | |
parent | added account page (diff) | |
download | pyload-9ea1ab90b4705ef4d5ce37ded36a214f276c0a18.tar.xz |
add and delete accounts, db will be resetted
Diffstat (limited to 'module/database')
-rw-r--r-- | module/database/AccountDatabase.py | 8 | ||||
-rw-r--r-- | module/database/DatabaseBackend.py | 10 |
2 files changed, 11 insertions, 7 deletions
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, ' |