Add functions to add/delete users and retrieve ato/ase from database

This commit is contained in:
Klaus-Uwe Mitterer 2017-02-08 12:49:05 +01:00
parent 5c2c7d1a5e
commit e2de6dac6a

View file

@ -63,6 +63,28 @@ class dbObject:
except:
return False
def deleteUser(self, cid):
self.executeQuery("DELETE FROM tokens WHERE cid = %i;" % int(cid))
self.commit()
def storeUser(self, cid, ato, ase):
self.executeQuery("INSERT INTO tokens VALUES(%i, '%s', '%s');" % (int(cid), ato, ase))
self.commit()
def ato(self, cid):
try:
self.executeQuery("SELECT ato FROM tokens WHERE cid = %i;" % int(cid))
return self.cur.fetchone()
except:
return False
def ase(self, cid):
try:
self.executeQuery("SELECT ase FROM tokens WHERE cid = %i;" % int(cid))
return self.cur.fetchone()
except:
return False
def dbHelper():
if setuptools.dbtype() == SQLITE:
return dbObject(dbtype=SQLITE, path=setuptools.dbpath())