forked from pyload/pyload
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccountDatabase.py
More file actions
29 lines (20 loc) · 913 Bytes
/
AccountDatabase.py
File metadata and controls
29 lines (20 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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()