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 518b090670dabfab33e87c5caff6c6feba267445..4faf8156936648f0963dc321260dfc3f4f0e1ae8 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 d81f5ae192d3e995cbe84e5a2f4fc9dcae2ec1ac..0756b3a5edc9469983ab872e29bd3a2e815b9b1a 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 b6d14c56699d7fbedf35efdbf1609554c773594e..f8597f6c47242eca01d3e701cf44b95f7bfd3523 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