summaryrefslogtreecommitdiffstats
path: root/pyload/database/AccountDatabase.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/database/AccountDatabase.py')
-rw-r--r--pyload/database/AccountDatabase.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/pyload/database/AccountDatabase.py b/pyload/database/AccountDatabase.py
new file mode 100644
index 000000000..3ca841fbc
--- /dev/null
+++ b/pyload/database/AccountDatabase.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+
+from pyload.Api import AccountInfo
+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')
+
+ 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]
+
+ @async
+ def saveAccounts(self, data):
+
+ self.c.executemany(
+ 'INSERT INTO accounts(plugin, loginname, owner, activated, shared, password, options) VALUES(?,?,?,?,?,?,?)',
+ data)
+
+ @async
+ def removeAccount(self, plugin, loginname):
+ self.c.execute('DELETE FROM accounts WHERE plugin=? AND loginname=?', (plugin, loginname))
+
+ @queue
+ def purgeAccounts(self):
+ self.c.execute('DELETE FROM accounts')
+
+AccountMethods.register() \ No newline at end of file