From 908d5012ca72d4a47d88e10cea211e94af03e1d6 Mon Sep 17 00:00:00 2001 From: vunhat_minh Date: Wed, 28 May 2014 14:28:49 +0900 Subject: [PATCH] update --- rainbow.db | Bin 2048 -> 0 bytes rainbowstream/db.py | 18 ++++++++++++++++++ rainbowstream/rainbow.py | 3 +++ 3 files changed, 21 insertions(+) delete mode 100644 rainbow.db diff --git a/rainbow.db b/rainbow.db deleted file mode 100644 index f440b2b539ca08c6a5360b14cdb92638521d909c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2048 zcmWFz^vNtqRY=P(%1ta$FlJz3U}R))P*7lC05VYlBbpe9PZZz3xJ5pImp#9#8n~0(aFbE0VtrL!NpmWn3)6pP8QlsZlT*0;3@?972GbnVEr&t($pMvQq#9Hxr1{^?%ELCkF;@Mlk1(fyyBT FMgTI5H9r6V 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, -- 2.25.1