auto create db
authorOrakaro <nhatminh_179@hotmail.com>
Tue, 27 May 2014 16:40:33 +0000 (01:40 +0900)
committerOrakaro <nhatminh_179@hotmail.com>
Tue, 27 May 2014 16:40:33 +0000 (01:40 +0900)
rainbowstream/config.py
rainbowstream/db.py
rainbowstream/rainbow.db [deleted file]
rainbowstream/table_def.py

index 518b090..4faf815 100644 (file)
@@ -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
index d81f5ae..0756b3a 100644 (file)
@@ -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 (file)
index fcd1099..0000000
Binary files a/rainbowstream/rainbow.db and /dev/null differ
index b6d14c5..f8597f6 100644 (file)
@@ -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