From: vunhat_minh Date: Wed, 28 May 2014 05:28:49 +0000 (+0900) Subject: update X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=908d5012ca72d4a47d88e10cea211e94af03e1d6;p=rainbowstream.git update --- diff --git a/rainbow.db b/rainbow.db deleted file mode 100644 index f440b2b..0000000 Binary files a/rainbow.db and /dev/null differ diff --git a/rainbowstream/db.py b/rainbowstream/db.py index 0756b3a..e0c7e84 100644 --- a/rainbowstream/db.py +++ b/rainbowstream/db.py @@ -14,6 +14,9 @@ class RainbowDB(): self.engine = create_engine('sqlite:///rainbow.db', echo=False) def store(self, tweet_id): + """ + Store tweet id + """ Session = sessionmaker(bind=self.engine) session = Session() m = Map(tweet_id) @@ -21,13 +24,28 @@ class RainbowDB(): session.commit() def rainbow_query(self, rid): + """ + Query base of rainbow id + """ Session = sessionmaker(bind=self.engine) session = Session() res = session.query(Map).filter("rainbow_id =:rid").params(rid=rid).all() return res def tweet_query(self, tid): + """ + Query base of tweet id + """ Session = sessionmaker(bind=self.engine) session = Session() res = session.query(Map).filter("tweet_id =:tid").params(tid=tid).all() return res + + def truncate(self): + """ + Truncate table + """ + Session = sessionmaker(bind=self.engine) + session = Session() + session.query(Map).delete() + session.commit() diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index 8a03f6f..29cba75 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -304,6 +304,7 @@ def quit(): """ Exit all """ + db.truncate() os.kill(g['stream_pid'], signal.SIGKILL) sys.exit() @@ -351,6 +352,8 @@ def stream(): # The Logo ascii_art() + g['stuff'] = '1' + home() # These arguments are optional: stream_args = dict( timeout=args.timeout,