OSDN Git Service

classify.py : add a mode that stores data in rec10 db.
[rec10/rec10-git.git] / rec10 / dbMySQL.py
index cce2e86..f2c4a88 100644 (file)
@@ -1233,6 +1233,34 @@ vim         ")
         WHERE \
         btime < DATE_SUB(now(),INTERVAL " + dhour + " HOUR )")
         self.close_db(db)
+    def new_auto_classify(self):
+        db = self.connect_db()
+        try:
+            db[1].execute('\
+            CREATE TABLE auto_classify \
+            (\
+            frompath VARCHAR(1024),\
+            topath VARCHAR(1024),\
+            do BOOLEAN\
+            )')
+        except Exception, inst:
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
+                recdblist.addCommonlogEX("Error", "new_auto_classify (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
+    def add_auto_classify(self, frompath="", topath=""):
+        db = self.connect_db()
+        db[1].execute('\
+        INSERT IGNORE into auto_classify \
+        (frompath,topath,do) \
+        values (%s,%s,0)', \
+                      (frompath, topath))
+        self.close_db(db)
+    def delete_old_auto_classify(self, frompath):
+        db = self.connect_db()
+        db[1].execute("\
+        DELETE FROM auto_classify \
+        WHERE \
+        frompath == %s", (frompath))
+        self.close_db(db)
     def update_db_to93(self):
         db = self.connect_db()
         self.drop_in_settings()