From eb9781ed75d3af8e4838806d57c853aa6cba1293 Mon Sep 17 00:00:00 2001 From: Orakaro Date: Wed, 28 May 2014 01:40:33 +0900 Subject: [PATCH] auto create db --- rainbowstream/config.py | 6 +++--- rainbowstream/db.py | 5 ++++- rainbowstream/rainbow.db | Bin 8192 -> 0 bytes rainbowstream/table_def.py | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) delete mode 100644 rainbowstream/rainbow.db diff --git a/rainbowstream/config.py b/rainbowstream/config.py index 518b090..4faf815 100644 --- a/rainbowstream/config.py +++ b/rainbowstream/config.py @@ -9,8 +9,8 @@ HOME_TWEET_NUM = 5 # Stream Domain -USER_DOMAIN = 'userstream.twitter.com', -PUBLIC_DOMAIN = 'stream.twitter.com', -SITE_DOMAIN = 'sitestream.twitter.com', +USER_DOMAIN = 'userstream.twitter.com' +PUBLIC_DOMAIN = 'stream.twitter.com' +SITE_DOMAIN = 'sitestream.twitter.com' # Actually called DOMAIN = USER_DOMAIN diff --git a/rainbowstream/db.py b/rainbowstream/db.py index d81f5ae..0756b3a 100644 --- a/rainbowstream/db.py +++ b/rainbowstream/db.py @@ -1,13 +1,16 @@ +import os from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from table_def import Map - +from .table_def import * class RainbowDB(): engine=None def __init__(self): + if not os.path.isfile('rainbow.db'): + init_db() self.engine = create_engine('sqlite:///rainbow.db', echo=False) def store(self, tweet_id): diff --git a/rainbowstream/rainbow.db b/rainbowstream/rainbow.db deleted file mode 100644 index fcd109907ed341b3d88ab24bef1debebc9d8f297..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8192 zcmeI#y$ZrG5C`x}D@qHZ;NW_Tpr9_kfK`HswQ8+{lT@rw@CykzyZV?ug`?L&baU7L zaUr>U4Eb$0pZTdtczZnWW5XRPlTy@WCL&vgCF2!J7P(g;b5?%~n_Bl;QEsWyjU*8e zfB*y_009U<00Izz00bZafj<{8s!**|)OBLw^)A`RCrPUxYA@0pc|BjVY;fIm&T)EJ zA1|wP!^0rb108ZOi8xsJev@6tT$03m9A+kmsw~_Vc()3g5@#p;b fJ_H~D0SG_<0uX=z1Rwwb2teQm1@g)!+iE*cKKv`1 diff --git a/rainbowstream/table_def.py b/rainbowstream/table_def.py index b6d14c5..f8597f6 100644 --- a/rainbowstream/table_def.py +++ b/rainbowstream/table_def.py @@ -14,4 +14,5 @@ class Map(Base): def __init__(self, tweet_id): self.tweet_id = tweet_id -Base.metadata.create_all(engine) \ No newline at end of file +def init_db(): + Base.metadata.create_all(engine) \ No newline at end of file -- 2.25.1