diff options
Diffstat (limited to 'pyload/database/AccountDatabase.py')
-rw-r--r-- | pyload/database/AccountDatabase.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/pyload/database/AccountDatabase.py b/pyload/database/AccountDatabase.py index 3ca841fbc..e432af192 100644 --- a/pyload/database/AccountDatabase.py +++ b/pyload/database/AccountDatabase.py @@ -7,23 +7,33 @@ from pyload.database import DatabaseMethods, queue, async class AccountMethods(DatabaseMethods): @queue def loadAccounts(self): - self.c.execute('SELECT plugin, loginname, owner, activated, shared, password, options FROM accounts') + self.c.execute('SELECT aid, plugin, loginname, owner, activated, shared, password, options FROM accounts') - return [(AccountInfo(r[0], r[1], r[2], activated=r[3] is 1, shared=r[4] is 1), r[5], r[6]) for r in self.c] + return [(AccountInfo(r[0], r[1], r[2], r[3], activated=r[4] is 1, shared=r[5] is 1), r[6], r[7]) for r in + self.c] + + @queue + def createAccount(self, plugin, loginname, password, owner): + self.c.execute('INSERT INTO accounts(plugin, loginname, password, owner) VALUES(?,?,?,?)', + (plugin, loginname, password, owner)) + + return self.c.lastrowid @async def saveAccounts(self, data): - self.c.executemany( - 'INSERT INTO accounts(plugin, loginname, owner, activated, shared, password, options) VALUES(?,?,?,?,?,?,?)', + 'UPDATE accounts SET ' + 'loginname=?, activated=?, shared=?, password=?, options=? ' + 'WHERE aid=?', data) @async - def removeAccount(self, plugin, loginname): - self.c.execute('DELETE FROM accounts WHERE plugin=? AND loginname=?', (plugin, loginname)) + def removeAccount(self, aid): + self.c.execute('DELETE FROM accounts WHERE aid=?', (aid,)) @queue def purgeAccounts(self): self.c.execute('DELETE FROM accounts') + AccountMethods.register()
\ No newline at end of file |