From: Orakaro Date: Tue, 27 May 2014 16:40:33 +0000 (+0900) Subject: auto create db X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=eb9781ed75d3af8e4838806d57c853aa6cba1293;p=rainbowstream.git auto create 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 fcd1099..0000000 Binary files a/rainbowstream/rainbow.db and /dev/null differ 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