OSDN Git Service

implement personal epg updating(beta).
[rec10/rec10-git.git] / rec10 / trunk / src / dbMySQL.py
index 3cd40ee..dd2c663 100644 (file)
@@ -65,47 +65,73 @@ class DB_MySQL:
         db = self.connect_db()
         dbexe=db[1].execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE ontv = %s",(ontv,))
         ret=[]
+        dls=[]
         if dbexe>0:
-            ret=db[1].fetchall()
+            dls=db[1].fetchall()
         self.close_db(db)
+        for dl in dls:
+            r=list(dl)
+            r[5]=r[5].strftime("%Y-%m-%d %H:%M:%S")
+            ret.append(r)
         return ret
     def select_by_chtxt_chdata(self,chtxt):
         db = self.connect_db()
         dbexe=db[1].execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE chtxt = %s",(chtxt,))
         ret=[]
+        dls=[]
         if dbexe>0:
-            ret=db[1].fetchall()
+            dls=db[1].fetchall()
         self.close_db(db)
+        for dl in dls:
+            r=list(dl)
+            r[5]=r[5].strftime("%Y-%m-%d %H:%M:%S")
+            ret.append(r)
         return ret
     def select_by_bctype_chdata(self,bctype):
         db = self.connect_db()
-        dbexe=db[1].execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE bctype = %s",(bctype,))
+        dbexe=db[1].execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime,status FROM chdata WHERE bctype = %s",(bctype,))
         ret=[]
+        dls=[]
         if dbexe>0:
-            ret=db[1].fetchall()
+            dls=db[1].fetchall()
         self.close_db(db)
+        for dl in dls:
+            #print dl
+            r=list(dl)
+            r[5]=r[5].strftime("%Y-%m-%d %H:%M:%S")
+            ret.append(r)
         return ret
     def select_by_ch_chdata(self,ch):
         db = self.connect_db()
         dbexe=db[1].execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE ch = %s",(ch,))
         ret=[]
+        dls=[]
         if dbexe>0:
-            ret=db[1].fetchall()
+            dls=db[1].fetchall()
         self.close_db(db)
+        for dl in dls:
+            r=list(dl)
+            r[5]=r[5].strftime("%Y-%m-%d %H:%M:%S")
+            ret.append(r)
         return ret
     def select_all_chdata(self):
         db = self.connect_db()
         dbexe=db[1].execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata ")
         ret=[]
+        dls=[]
         if dbexe>0:
-            ret=db[1].fetchall()
+            dls=db[1].fetchall()
         self.close_db(db)
+        for dl in dls:
+            r=list(dl)
+            r[5]=r[5].strftime("%Y-%m-%d %H:%M:%S")
+            ret.append(r)
         return ret
     def select_get_update_chdata(self,dhour):
         db = self.connect_db()
-        dbexe=db[1].execute("SELECT bctype,chtxt,status FROM chdata WHERE updatetime < DATE_SUB(now(),INTERVAL "+dhour+" HOUR) AND status > 0 ORDER BY status DESC")
+        dbexe=db[1].execute("SELECT bctype,chtxt,status FROM chdata WHERE ( updatetime < DATE_SUB(now(),INTERVAL "+dhour+" HOUR) AND status = 0 ) OR status > 1 ORDER BY status DESC")
         ret=[]
-        print dbexe
+        #print dbexe
         if dbexe>0:
             ret=db[1].fetchall()
         self.close_db(db)