From e2de6dac6a1923da2fdc918abba6fe02e3974bf8 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Wed, 8 Feb 2017 12:49:05 +0100 Subject: [PATCH] Add functions to add/delete users and retrieve ato/ase from database --- dbtools/__init__.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/dbtools/__init__.py b/dbtools/__init__.py index 92f6699..4e6f3ad 100644 --- a/dbtools/__init__.py +++ b/dbtools/__init__.py @@ -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())