From 3cb5d8861c802c2be5ce75356ce043333ebe2124 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Wed, 8 Feb 2017 15:26:21 +0100 Subject: [PATCH] Separate toggler from checker --- dbtools/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dbtools/__init__.py b/dbtools/__init__.py index 4a6a514..434382c 100644 --- a/dbtools/__init__.py +++ b/dbtools/__init__.py @@ -85,11 +85,8 @@ class dbObject: except: return False - def toggleTweet(self, cid): + def getTStatus(self, cid): try: - self.executeQuery("UPDATE tokens SET tweet = NOT tweet WHERE cid = %i;" % int(cid)) - self.commit() - self.executeQuery("SELECT tweet FROM tokens WHERE cid = %i;" % int(cid)) return True if self.cur.fetchone()[0] == 1 else False @@ -97,6 +94,12 @@ class dbObject: except: raise ValueError("No such user: %i" % int(cid)) + def toggleTweet(self, cid): + self.executeQuery("UPDATE tokens SET tweet = NOT tweet WHERE cid = %i;" % int(cid)) + self.commit() + + return getTStatus + def addFish(self, cid): self.executeQuery("UPDATE tokens SET fish = fish + 1 WHERE cid = %i;" % int(cid)) self.commit()