theme on DB
[rainbowstream.git] / rainbowstream / db.py
index fabc3a4..775c856 100644 (file)
@@ -1,5 +1,6 @@
 import os
 from sqlalchemy import create_engine
+from sqlalchemy import update
 from sqlalchemy.orm import sessionmaker
 from .table_def import *
 
@@ -19,8 +20,8 @@ class RainbowDB():
         """
         Session = sessionmaker(bind=self.engine)
         session = Session()
-        m = Tweet(tweet_id)
-        session.add(m)
+        t = Tweet(tweet_id)
+        session.add(t)
         session.commit()
 
     def rainbow_to_tweet_query(self, rid):
@@ -68,3 +69,33 @@ class RainbowDB():
         session = Session()
         res = session.query(Message).filter_by(message_id=mid).all()
         return res
+
+    def theme_store(self, theme_name):
+        """
+        Store theme
+        """
+        Session = sessionmaker(bind=self.engine)
+        session = Session()
+        th = Theme(theme_name)
+        session.add(th)
+        session.commit()
+
+    def theme_update(self, theme_name):
+        """
+        Update theme
+        """
+        Session = sessionmaker(bind=self.engine)
+        session = Session()
+        res = session.query(Theme).all()
+        for r in res:
+            r.theme_name = theme_name
+        session.commit()
+
+    def theme_query(self):
+        """
+        Query theme
+        """
+        Session = sessionmaker(bind=self.engine)
+        session = Session()
+        res = session.query(Theme).all()
+        return res