OSDN Git Service

implement update(to 0.9.10)
[rec10/rec10-git.git] / rec10 / trunk / src / dbMySQL.py
index 0c618a3..8d33d93 100644 (file)
@@ -5,6 +5,7 @@
 import MySQLdb
 import recdblist
 import warnings
+import traceback
 
 from decimal import Decimal
 class DB_MySQL:
@@ -26,8 +27,9 @@ class DB_MySQL:
             cur.execute('CREATE DATABASE ' + dbname + " DEFAULT CHARACTER SET utf8")
             cur.close()
             con.close()
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "init (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         db = self.connect_db()
         try:
             db[1].execute('\
@@ -47,10 +49,13 @@ class DB_MySQL:
             epgetime DATETIME,\
             epgduplicate TINYINT DEFAULT 0,\
             epgchange TINYINT DEFAULT 0,\
+            epgexp VARCHAR(200),\
+            counter TINYINT DEFAULT -1,\
             UNIQUE uni (type,chtxt,title,btime,deltaday)\
             )')
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "init (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
         self.new_epg_timeline("")
         self.new_in_timeline_log()
@@ -75,15 +80,16 @@ class DB_MySQL:
         db = self.connect_db()
         try:
             db[1].execute('drop table epg_ch')
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and (inst[0]==1050 or inst[0]==1051))):
+                recdblist.Commonlogex("Error", "new_epg_ch drop (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
+
         try:
             db[1].execute('\
             CREATE TABLE epg_ch \
             (\
             bctype VARCHAR(15),\
-            ontv VARCHAR(30) PRIMARY KEY,\
-            chtxt VARCHAR(20),\
+            chtxt VARCHAR(20) PRIMARY KEY,\
             ch VARCHAR(20),\
             csch VARCHAR(20),\
             chname VARCHAR(100),\
@@ -91,39 +97,24 @@ class DB_MySQL:
             status TINYINT,\
             isshow TINYINT\
             )')
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "new_epg_ch (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
+
         self.close_db(db)
-    def add_epg_ch(self, bctype, ontv, chtxt, ch, csch, updatetime):
+    def add_epg_ch(self, bctype, chtxt, ch, csch, updatetime):
         db = self.connect_db()
         db[1].execute('\
         INSERT INTO epg_ch \
-        VALUES (%s,%s,%s,%s,%s,"",%s,%s,%s)', \
-                      (bctype, ontv, chtxt, ch, csch, updatetime, "1","1"))
-        self.close_db(db)
-    def select_by_ontv_epg_ch(self, ontv):
-        db = self.connect_db()
-        dbexe = db[1].execute("\
-        SELECT bctype,ontv,chtxt,ch,csch,updatetime \
-        FROM epg_ch \
-        WHERE ontv = %s", \
-                              (ontv,))
-        ret = []
-        dls = []
-        if dbexe > 0:
-            dls = db[1].fetchall()
+        VALUES (%s,%s,%s,%s,"",%s,%s,%s)', \
+                      (bctype, chtxt, ch, csch, updatetime, "1","1"))
         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_epg_ch(self, chtxt):
         db = self.connect_db()
         dbexe = db[1].execute("\
-        SELECT bctype,ontv,chtxt,ch,csch,updatetime \
+        SELECT bctype,chtxt,ch,csch,updatetime \
         FROM epg_ch \
-        WHERE chtxt = %s", \
+        WHERE chtxt LIKE %s", \
                               (chtxt,))
         ret = []
         dls = []
@@ -132,13 +123,13 @@ class DB_MySQL:
         self.close_db(db)
         for dl in dls:
             r = list(dl)
-            r[5] = r[5].strftime("%Y-%m-%d %H:%M:%S")
+            r[4] = r[4].strftime("%Y-%m-%d %H:%M:%S")
             ret.append(r)
         return ret
     def select_by_bctype_epg_ch(self, bctype):
         db = self.connect_db()
         dbexe = db[1].execute("\
-        SELECT bctype,ontv,chtxt,ch,csch,updatetime,status \
+        SELECT bctype,chtxt,ch,csch,updatetime,status \
         FROM epg_ch \
         WHERE bctype = %s", \
                               (bctype,))
@@ -150,15 +141,15 @@ class DB_MySQL:
         for dl in dls:
             #recdblist.printutf8(dl)
             r = list(dl)
-            r[5] = r[5].strftime("%Y-%m-%d %H:%M:%S")
-            r[6] = str(r[6])
+            r[4] = r[4].strftime("%Y-%m-%d %H:%M:%S")
+            r[5] = str(r[5])
             ret.append(r)
         return ret
     def select_by_ch_epg_ch(self, ch):
         db = self.connect_db()
         dbexe = db[1].execute("\
         SELECT \
-        bctype,ontv,chtxt,ch,csch,updatetime \
+        bctype,chtxt,ch,csch,updatetime \
         FROM epg_ch \
         WHERE ch = %s", \
                               (ch,))
@@ -169,13 +160,13 @@ class DB_MySQL:
         self.close_db(db)
         for dl in dls:
             r = list(dl)
-            r[5] = r[5].strftime("%Y-%m-%d %H:%M:%S")
+            r[4] = r[4].strftime("%Y-%m-%d %H:%M:%S")
             ret.append(r)
         return ret
     def select_all_epg_ch(self):
         db = self.connect_db()
         dbexe = db[1].execute("\
-        SELECT bctype,ontv,chtxt,ch,csch,updatetime \
+        SELECT bctype,chtxt,ch,csch,updatetime \
         FROM epg_ch \
         ")
         ret = []
@@ -185,7 +176,7 @@ class DB_MySQL:
         self.close_db(db)
         for dl in dls:
             r = list(dl)
-            r[5] = r[5].strftime("%Y-%m-%d %H:%M:%S")
+            r[4] = r[4].strftime("%Y-%m-%d %H:%M:%S")
             ret.append(r)
         return ret
     def set_new_status(self,dhour):
@@ -246,14 +237,14 @@ class DB_MySQL:
                       (status, bctype)\
                       )
         self.close_db(db)
-    def update_chname_by_ontv_epg_ch(self,ontv,chname):
+    def update_chname_by_chtxt_epg_ch(self,chtxt,chname):
         db = self.connect_db()
         db[1].execute("\
         UPDATE epg_ch \
         SET \
         chname=%s \
-        WHERE ontv = %s", \
-                      (chname, ontv)\
+        WHERE chtxt = %s", \
+                      (chname, chtxt)\
                       )
         self.close_db(db)
     def add_auto_proc_tmp(self,type,title,chtxt):
@@ -268,8 +259,10 @@ class DB_MySQL:
         db = self.connect_db()
         try:
             db[1].execute('drop table auto_proc_tmp')
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and (inst[0]==1050 or inst[0]==1051))):
+                recdblist.Commonlogex("Error", "new_auto_proc_tmp drop (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
+
         try:
             db[1].execute('\
             CREATE TABLE auto_proc_tmp \
@@ -279,22 +272,28 @@ class DB_MySQL:
             chtxt VARCHAR(30),\
             UNIQUE unibayeskey(title)\
             )')
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "new_auto_proc_tmp (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
+
         self.close_db(db)
     def update_auto_proc(self):
         db = self.connect_db()
         try:
             db[1].execute('INSERT INTO auto_proc SELECT * FROM auto_proc_tmp')
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "update_auto_proc (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
+
         self.close_db(db)
     def new_auto_proc(self):
         db = self.connect_db()
         try:
             db[1].execute('drop table auto_proc')
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and (inst[0]==1050 or inst[0]==1051))):
+                recdblist.Commonlogex("Error", "new_auto_proc drop (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
+
         try:
             db[1].execute('\
             CREATE TABLE auto_proc \
@@ -304,8 +303,10 @@ class DB_MySQL:
             chtxt VARCHAR(30),\
             UNIQUE unibayeskey(title)\
             )')
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "new_auto_proc (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
+
         self.close_db(db)
     def add_auto_proc(self,type,title,chtxt):
         db = self.connect_db()
@@ -319,8 +320,9 @@ class DB_MySQL:
         db = self.connect_db()
         try:
             db[1].execute('drop table in_settings')
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and (inst[0]==1050 or inst[0]==1051))):
+                recdblist.Commonlogex("Error", "drop_in_settings (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
     def new_in_settings(self):
         db = self.connect_db()
@@ -333,9 +335,11 @@ class DB_MySQL:
             auto_opt VARCHAR(20),\
             auto_del_tmp TINYINT\
             )')
-            db[1].execute("INSERT IGNORE into in_settings VALUE (0,0,\"G\",1)")
-        except:
-            ""
+            db[1].execute("INSERT IGNORE into in_settings VALUE (0,0,\"H\",1)")
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "new_in_settings (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
+
         self.close_db(db)
     def select_all_in_settings(self):
         db = self.connect_db()
@@ -393,8 +397,10 @@ class DB_MySQL:
             category VARCHAR(100),\
             UNIQUE uni (chtxt,title,btime,category)\
             )')
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "new_in_timeline_log (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
+
         self.close_db(db)
     def select_chtxt_by_title_timeline_log(self,title):
         db = self.connect_db()
@@ -411,22 +417,22 @@ class DB_MySQL:
                 ret=retdb[0][0]
         self.close_db(db)
         return ret
-    def add_timeline(self, type="", chtxt="", title="", btime="", etime="", deltatime="", deltaday="", opt=""):
+    def add_timeline(self, type="", chtxt="", title="", btime="", etime="", deltatime="", deltaday="", opt="" ,counter=-1):
         db = self.connect_db()
         db[1].execute('\
         INSERT IGNORE into timeline \
-        (type,chtxt,title,btime,etime,deltatime,deltaday,opt) \
-        values (%s,%s,%s,%s,%s,%s,%s,%s)', \
-                      (type, chtxt, title, btime, etime, deltatime, deltaday, opt))
+        (type,chtxt,title,btime,etime,deltatime,deltaday,opt,counter) \
+        values (%s,%s,%s,%s,%s,%s,%s,%s,%s)', \
+                      (type, chtxt, title, btime, etime, deltatime, deltaday, opt ,counter))
         ##db.commit()
         self.close_db(db)
-    def update_epg_timeline(self,type,chtxt,title,btime,epgbtime,epgetime,epgtitle):
+    def update_epg_timeline(self,type,chtxt,title,btime,epgbtime,epgetime,epgtitle,epgexp):
         db = self.connect_db()
         db[1].execute('\
         UPDATE timeline \
-        SET epgbtime=%s,epgetime=%s,epgtitle=%s \
+        SET epgbtime=%s,epgetime=%s,epgtitle=%s,epgexp=%s \
         WHERE type=%s AND chtxt=%s AND title=%s AND btime=%s ', \
-                      (epgbtime,epgetime,epgtitle,type, chtxt, title, btime))
+                      (epgbtime,epgetime,epgtitle,epgexp,type, chtxt, title, btime))
         ##db.commit()
         self.close_db(db)
     def update_status_change_timeline(self,type,chtxt,title,btime,epgchange):
@@ -462,7 +468,7 @@ class DB_MySQL:
         db = self.connect_db()
         recdata = []
         dbr = db[1].execute("\
-        SELECT type, chtxt, title, btime, etime, deltatime ,deltaday ,opt ,epgbtime ,epgetime ,epgtitle ,epgduplicate ,epgchange \
+        SELECT type, chtxt, title, btime, etime, deltatime ,deltaday ,opt ,epgbtime ,epgetime ,epgtitle ,epgduplicate ,epgchange ,counter\
         FROM timeline")
         dbl = db[1].fetchall()
         self.close_db(db)
@@ -474,7 +480,7 @@ class DB_MySQL:
         recdatum = []
         #dbr=db[1].execute("SELECT type, chtxt, title, btime, etime, deltatime ,deltaday ,opt FROM rectime WHERE btime < DATE_SUB(now(),INTERVAL "+dminutes+" MINUTE ) AND btime > DATE_ADD(now(),INTERVAL "+dminutes+" MINUTE )")
         dbr = db[1].execute("SELECT \
-        type, chtxt, title, btime, etime, deltatime ,deltaday ,opt ,epgbtime ,epgetime ,epgtitle ,epgduplicate ,epgchange \
+        type, chtxt, title, btime, etime, deltatime ,deltaday ,opt ,epgbtime ,epgetime ,epgtitle ,epgduplicate ,epgchange ,counter\
         FROM timeline \
         WHERE btime BETWEEN DATE_SUB(now(),INTERVAL " + dminutes + " MINUTE ) AND \
         DATE_ADD(now(),INTERVAL " + dminutes + " MINUTE )")
@@ -489,7 +495,7 @@ class DB_MySQL:
         recdatum = []
         #dbr=db[1].execute("SELECT type, chtxt, title, btime, etime, deltatime ,deltaday ,opt FROM rectime WHERE btime < DATE_SUB(now(),INTERVAL "+dminutes+" MINUTE ) AND btime > DATE_ADD(now(),INTERVAL "+dminutes+" MINUTE )")
         dbr = db[1].execute("SELECT \
-        type, chtxt, title, btime, etime, deltatime ,deltaday ,opt ,epgbtime ,epgetime ,epgtitle ,epgduplicate ,epgchange \
+        type, chtxt, title, btime, etime, deltatime ,deltaday ,opt ,epgbtime ,epgetime ,epgtitle ,epgduplicate ,epgchange ,counter\
         FROM timeline \
         WHERE btime > %s AND \
         btime < %s AND title = %s",(btime,btime2,title))
@@ -504,7 +510,7 @@ class DB_MySQL:
         recdatum = []
         #dbr=db[1].execute("SELECT type, chtxt, title, btime, etime, deltatime ,deltaday ,opt FROM rectime WHERE btime < DATE_SUB(now(),INTERVAL "+dminutes+" MINUTE ) AND btime > DATE_ADD(now(),INTERVAL "+dminutes+" MINUTE )")
         dbr = db[1].execute("SELECT \
-        type, chtxt, title, btime, etime, deltatime ,deltaday ,opt ,epgbtime ,epgetime ,epgtitle ,epgduplicate ,epgchange \
+        type, chtxt, title, btime, etime, deltatime ,deltaday ,opt ,epgbtime ,epgetime ,epgtitle ,epgduplicate ,epgchange ,counter\
         FROM timeline \
         WHERE btime > %s AND \
         etime < %s",(btime,etime))
@@ -519,10 +525,25 @@ class DB_MySQL:
         recdatum = []
         #dbr=db[1].execute("SELECT type, chtxt, title, btime, etime, deltatime ,deltaday ,opt FROM rectime WHERE btime < DATE_SUB(now(),INTERVAL "+dminutes+" MINUTE ) AND btime > DATE_ADD(now(),INTERVAL "+dminutes+" MINUTE )")
         dbr = db[1].execute("SELECT \
-        type, chtxt, title, btime, etime, deltatime ,deltaday ,opt ,epgbtime ,epgetime ,epgtitle ,epgduplicate ,epgchange \
+        type, chtxt, title, btime, etime, deltatime ,deltaday ,opt ,epgbtime ,epgetime ,epgtitle ,epgduplicate ,epgchange ,counter\
+        FROM timeline \
+        WHERE epgbtime >= %s AND \
+        epgetime <= %s",(epgbtime,epgetime))
+        dbl = db[1].fetchall()
+        self.close_db(db)
+        #recdblist.printutf8(dbl)
+        if dbr > 0:
+            recdatum=self.getdic_timeline(dbl)
+        return recdatum
+    def select_byepgtime_over_timeline(self,epgbtime,epgetime):
+        db = self.connect_db()
+        recdatum = []
+        #dbr=db[1].execute("SELECT type, chtxt, title, btime, etime, deltatime ,deltaday ,opt FROM rectime WHERE btime < DATE_SUB(now(),INTERVAL "+dminutes+" MINUTE ) AND btime > DATE_ADD(now(),INTERVAL "+dminutes+" MINUTE )")
+        dbr = db[1].execute("SELECT \
+        type, chtxt, title, btime, etime, deltatime ,deltaday ,opt ,epgbtime ,epgetime ,epgtitle ,epgduplicate ,epgchange ,counter\
         FROM timeline \
-        WHERE epgbtime > %s AND \
-        epgetime < %s",(epgbtime,epgetime))
+        WHERE (NOT(( timeline.epgetime <= %s )OR( timeline.epgbtime >= %s )))"\
+        ,(epgbtime,epgetime))
         dbl = db[1].fetchall()
         self.close_db(db)
         #recdblist.printutf8(dbl)
@@ -574,10 +595,10 @@ class DB_MySQL:
         """
         db = self.connect_db()
         dbexe = "SELECT type,epg_ch.bctype,timeline.chtxt,title FROM timeline INNER JOIN epg_ch ON timeline.chtxt=epg_ch.chtxt"
-        dbexe = dbexe + " WHERE ((NOT(( timeline.epgetime <= %s )OR( timeline.epgbtime >= %s ))) OR ((timeline.epgbtime = %s) AND (timeline.epgetime = %s) ) )"
+        dbexe = dbexe + " WHERE (NOT(( timeline.epgetime <= %s )OR( timeline.epgbtime >= %s )))"
         Srec = 0
         Trec = 0
-        db[1].execute(dbexe, (epgbtime, epgetime,epgbtime,epgetime))
+        db[1].execute(dbexe, (epgbtime, epgetime))
         dbl=db[1].fetchall()
         for typet, bctypet, chtxtt, titlet in dbl:
             if (typet == recdblist.REC_RESERVE) or (typet == recdblist.REC_FINAL_RESERVE) or (typet == recdblist.REC_KEYWORD) or (typet == recdblist.REC_KEYWORD_EVERY_SOME_DAYS):
@@ -610,7 +631,7 @@ class DB_MySQL:
         recdatum = []
         #dbr=db[1].execute("SELECT type, chtxt, title, btime, etime, deltatime ,deltaday ,opt FROM rectime WHERE btime < DATE_SUB(now(),INTERVAL "+dminutes+" MINUTE ) AND btime > DATE_ADD(now(),INTERVAL "+dminutes+" MINUTE )")
         dbr = db[1].execute("SELECT \
-        type, chtxt, title, btime, etime, deltatime ,deltaday ,opt ,epgbtime ,epgetime ,epgtitle ,epgduplicate ,epgchange \
+        type, chtxt, title, btime, etime, deltatime ,deltaday ,opt ,epgbtime ,epgetime ,epgtitle ,epgduplicate ,epgchange ,counter\
         FROM timeline \
         WHERE btime > %s AND \
         etime < %s\
@@ -623,7 +644,7 @@ class DB_MySQL:
         return recdatum
     def getdic_timeline(self,timelinelists):
         recdatum=[]
-        for typet, chtxt, title, btime, etime, deltatime, deltaday, opt ,epgbtimet , epgetimet ,epgtitlet ,epgduplicatet ,epgchanget  in timelinelists:
+        for typet, chtxt, title, btime, etime, deltatime, deltaday, opt ,epgbtimet , epgetimet ,epgtitlet ,epgduplicatet ,epgchanget ,countert in timelinelists:
             ret = {}
             ret['type'] = typet
             ret['chtxt'] = chtxt
@@ -651,6 +672,10 @@ class DB_MySQL:
             elif typet == recdblist.REC_KEYWORD_EVERY_SOME_DAYS:
                 ret['deltatime'] = deltatime
                 ret['deltaday'] = deltaday
+            try:
+                ret['counter'] = int(countert)
+            except:
+                ret['counter']=-1
             recdatum.append(ret)
         return recdatum
     def delete_old_timeline(self, dhour):
@@ -669,10 +694,13 @@ class DB_MySQL:
             (\
             id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,\
             keyword VARCHAR(200),\
+            auto TINYINT DEFAULT 0,\
+            opt VARCHAR(20),\
             UNIQUE unijbk (keyword)\
             )")
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "new_in_auto_jbk_key (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
     def add_in_auto_jbk_key(self,key):
         db = self.connect_db()
@@ -686,7 +714,7 @@ class DB_MySQL:
     def select_all_in_auto_jbk_key(self):
         db = self.connect_db()
         dbexe = db[1].execute("\
-        SELECT keyword \
+        SELECT keyword,auto,opt \
         FROM in_auto_jbk_key \
         ")
         ret = []
@@ -698,8 +726,9 @@ class DB_MySQL:
         db = self.connect_db()
         try:
             db[1].execute('drop table in_status')
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and (inst[0]==1050 or inst[0]==1051))):
+                recdblist.Commonlogex("Error", "drop_in_status (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
     def new_in_status(self):
         db = self.connect_db()
@@ -711,11 +740,13 @@ class DB_MySQL:
             terec TINYINT DEFAULT 0,\
             bscsrec TINYINT DEFAULT 0,\
             b252ts TINYINT DEFAULT 0,\
-            installed TINYINT DEFAULT 0\
+            installed TINYINT DEFAULT 0,\
+            version TINYINT\
             )")
-            db[1].execute("INSERT IGNORE into in_status VALUE (0,0,0,0,0)")
-        except:
-            ""
+            db[1].execute("INSERT IGNORE into in_status VALUE (0,0,0,0,0,0)")
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "new_in_status (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
     def select_all_in_status(self):
         db = self.connect_db()
@@ -736,7 +767,29 @@ class DB_MySQL:
             r[3]=str(r[3])
             ret.append(r)
         return ret
-        
+    def select_version_in_status(self):
+        db = self.connect_db()
+        version=0
+        try:
+            dbexe = db[1].execute("\
+            SELECT version \
+            FROM in_status \
+            ")
+            if dbexe > 0:
+                dls = db[1].fetchall()
+            self.close_db(db)
+            for dl in dls:
+                r = list(dl)
+                version=int(str(r[0]))
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "select_version_in_status (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
+        return version
+    def change_version_in_status(self,version):
+        db = self.connect_db()
+        db[1].execute("\
+        UPDATE in_status SET version=%s",str(version))
+        self.close_db(db)
     def change_ts2avi_in_status(self,i):
         """
         statuをiだけ増減する
@@ -796,6 +849,14 @@ class DB_MySQL:
         db[1].execute("\
         UPDATE in_status SET installed=1")
         self.close_db(db)
+    def change_chscaned_in_status(self):
+        """
+        installedを設定する
+        """
+        db = self.connect_db()
+        db[1].execute("\
+        UPDATE in_status SET installed=2")
+        self.close_db(db)
     def new_epg_timeline(self, bctype):
         db = self.connect_db()
         try:
@@ -803,8 +864,9 @@ class DB_MySQL:
             DELETE FROM epg_timeline \
             WHERE bctype = %s", \
                           (bctype,))
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and (inst[0]==1007 or inst[0]==1146))or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "new_epg_timeline delete (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         try:
             db[1].execute("\
             CREATE TABLE epg_timeline \
@@ -819,8 +881,9 @@ class DB_MySQL:
             category VARCHAR(100),\
             UNIQUE unitv(bctype,channel,start,stop,title)\
             )")
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "new_epg_timeline (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         #db.commit()
         self.close_db(db)
     def add_epg_timeline(self, bctype, channel, start, stop, title, desc,longdesc, category):
@@ -849,13 +912,13 @@ class DB_MySQL:
         epg_ch.chtxt,title,start,stop,exp,longexp,category \
         FROM epg_timeline \
         INNER JOIN epg_ch \
-        WHERE epg_ch.ontv=epg_timeline.channel \
+        WHERE epg_ch.chtxt LIKE epg_timeline.channel \
         AND \
         start >= %s \
         AND \
         start <= %s \
         AND \
-        epg_ch.chtxt=%s"
+        epg_ch.chtxt LIKE %s"
         dbcmd = db[1].execute(dbexe, (btime, etime, chtxt))
         retall = []
         if dbcmd > 0:
@@ -869,7 +932,7 @@ class DB_MySQL:
         epg_ch.chtxt,title,start,stop,exp,longexp,category \
         FROM epg_timeline \
         INNER JOIN epg_ch \
-        WHERE epg_ch.ontv=epg_timeline.channel \
+        WHERE epg_ch.chtxt=epg_timeline.channel \
         AND \
         start >= %s \
         AND \
@@ -900,8 +963,9 @@ class DB_MySQL:
             UNIQUE unibayeskey(keychar,chtxt)\
             )')
             db[1].execute('CREATE INDEX keycharindex ON in_auto_bayes_key(keychar)')
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "new_in_auto_bayes_key (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
 
     def add_in_auto_bayes_key(self,key,chtxt,ratio_rec,ratio_all):
@@ -961,8 +1025,9 @@ class DB_MySQL:
                 VALUES (%s,%s,%s,%s)\
                 ON DUPLICATE KEY UPDATE \
                 ratio_all=CONVERT((ratio_all*%s+%s)/%s,DECIMAL(32,14))",retl)
-            except:
-                ""
+            except Exception, inst:
+                if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                    recdblist.Commonlogex("Error", "change_multi_ratio_all_in_auto_bayes_key (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
     def change_ratio_rec_reduce_in_auto_bayes_key(self,chtxt,beforenum,newnum):
         beforenum=str(beforenum)
@@ -992,8 +1057,9 @@ class DB_MySQL:
                 VALUES (%s,%s,%s,%s)\
                 ON DUPLICATE KEY UPDATE \
                 ratio_rec=CONVERT((ratio_rec*%s+%s)/%s,DECIMAL(32,14))",retl)
-            except:
-                ""
+            except Exception, inst:
+                if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                    recdblist.Commonlogex("Error", "change_multi_ratio_rec_in_auto_bayes_key (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
     def select_by_key_in_auto_bayes_key(self,key,chtxt):
         db = self.connect_db()
@@ -1010,7 +1076,6 @@ class DB_MySQL:
             return dls[0]
         else:
             return dls
-
     def new_auto_timeline_keyword(self):
         db = self.connect_db()
         try:
@@ -1024,8 +1089,9 @@ class DB_MySQL:
             etime DATETIME,\
             UNIQUE uni (chtxt,title,btime,etime)\
             )')
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "new_auto_timeline_keyword (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
     def add_auto_timeline_keyword(self,chtxt="", title="", btime="", etime=""):
         db = self.connect_db()
         db[1].execute('\
@@ -1056,8 +1122,9 @@ class DB_MySQL:
             point INT,\
             UNIQUE uni (chtxt,title,btime,etime)\
             )')
-        except:
-            ""
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.Commonlogex("Error", "new_auto_timeline_bayes (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
     def add_auto_timeline_bayes(self,chtxt="", title="", btime="", etime="",point=""):
         db = self.connect_db()
         db[1].execute('\
@@ -1073,3 +1140,61 @@ class DB_MySQL:
         WHERE \
         btime < DATE_SUB(now(),INTERVAL " + dhour + " HOUR )")
         self.close_db(db)
+    def update_db_to93(self):
+        db = self.connect_db()
+        self.drop_in_settings()
+        self.new_in_settings()
+        db[1].execute("\
+        ALTER TABLE timeline ADD epgtitle VARCHAR(100),\
+        ADD epgbtime DATETIME,\
+        ADD epgetime DATETIME,\
+        ADD epgduplicate TINYINT DEFAULT 0,\
+        ADD epgchange TINYINT DEFAULT 0")
+        db[1].execute("\
+        ALTER TABLE in_status ADD version TINYINT")
+        self.close_db(db)
+        self.change_version_in_status("93")
+    def update_db_93to94(self):
+        db = self.connect_db()
+        self.drop_in_settings()
+        self.new_in_settings()
+        db[1].execute("\
+        ALTER TABLE timeline ADD counter TINYINT DEFAULT -1")
+        self.close_db(db)
+        self.change_version_in_status("94")
+    def update_db_94to95(self):
+        db = self.connect_db()
+        self.drop_in_settings()
+        self.new_in_settings()
+        db[1].execute("\
+        ALTER TABLE timeline ADD epgexp VARCHAR(200)")
+        self.close_db(db)
+        self.change_version_in_status("95")
+    def update_db_95to96(self):
+        db = self.connect_db()
+        self.drop_in_settings()
+        self.new_in_settings()
+        self.close_db(db)
+        self.change_version_in_status("96")
+    def update_db_96to98(self):
+        db = self.connect_db()
+        self.drop_in_settings()
+        self.new_in_settings()
+        self.close_db(db)
+        self.change_version_in_status("98")
+    def update_db_98to100(self):
+        ###ここで前のepg_chをバックアップしてchtxtの変換をする必要がある。
+        db = self.connect_db()
+        self.drop_in_settings()
+        self.new_in_settings()
+        db[1].execute("\
+        UPDATE timeline INNER JOIN epg_ch ON timeline.chtxt=epg_ch.chtxt SET timeline.chtxt=CONCAT(CONCAT(epg_ch.ch,'_'),epg_ch.csch)")
+        db[1].execute("\
+        ALTER TABLE epg_ch DROP ontv")
+        db[1].execute("\
+        ALTER TABLE in_auto_jbk_key ADD auto TINYINT DEFAULT 0")
+        db[1].execute("\
+        ALTER TABLE in_auto_jbk_key ADD opt VARCHAR(20) DEFAULT \"\"")
+        self.close_db(db)
+        self.change_installed_in_status()#チャンネルスキャンをさせる
+        self.change_version_in_status("100")
\ No newline at end of file