Exemplo n.º 1
0
    def getSubList(self):
        self.config = {
            'host': 'host',
            'port': 3306,
            'user': '******',
            'passwd': 'pwd',
            'db': 'weCatch',
            'charset': 'utf8',
        }
        self.conn = mdb.connect(**self.config)

        cursor = self.conn.cursor()
        try:
            sql = "select subEname,subName from subscription where status= 1 "
            cursor.execute(sql)
            temp = cursor.fetchall()
            return temp
            self.conn.commit()
        except:
            import traceback
            traceback.print_exc()
            self.conn.rollback()
        finally:
            cursor.close()
            self.conn.close()
Exemplo n.º 2
0
    def checkExist(self, title):
        # 检查查到的文章标题是否存在
        self.config = {
            'host': 'host',
            'port': 3306,
            'user': '******',
            'passwd': 'pwd',
            'db': 'weCatch',
            'charset': 'utf8',
        }
        self.conn = mdb.connect(**self.config)

        cursor = self.conn.cursor()
        try:
            sql = "select id from queue where title ='%s'  " % (title)
            cursor.execute(sql)
            # 如果没有设置自动提交事务,则这里需要手动提交一次
            self.conn.commit()
            temp = cursor.fetchall()
            if (temp):
                return False
            else:
                return True
        except:
            import traceback
            traceback.print_exc()
            # 发生错误时会滚
            self.conn.rollback()
        finally:

            # 关闭游标连接
            cursor.close()
            # 关闭数据库连接
            self.conn.close()
Exemplo n.º 3
0
 def upSubTime(self, Ename):
     config = {
         'host': 'host',
         'port': 3306,
         'user': '******',
         'passwd': 'pwd',
         'db': 'weCatch',
         'charset': 'utf8',
     }
     conn = mdb.connect(**config)
     lastTime = time.strftime('%Y-%m-%d')
     cursor = conn.cursor()
     try:
         sql = (
             "update subscription SET catchTime ='%s'  WHERE subEname = '%s'"
             % (lastTime, Ename))
         cursor.execute(sql)
         conn.commit()
     except:
         import traceback
         traceback.print_exc()
         conn.rollback()
     finally:
         cursor.close()
         conn.close()
Exemplo n.º 4
0
    def insert_save(self, url, name, listaText):
        self.config = {
            'host': '',
            'port': 3306,
            'user': '******',
            'passwd': 'pwd',
            'db': 'weCatch',
            'charset': 'utf8',
        }
        self.conn = mdb.connect(**self.config)

        cursor = self.conn.cursor()
        try:
            sql = (
                "insert into queue (url,subname,title) values('%s','%s','%s')"
                % (url, name, listaText))
            print(sql)
            cursor.execute(sql)

            self.conn.commit()
        except:
            import traceback
            traceback.print_exc()
            self.conn.rollback()
        finally:
            cursor.close()
            self.conn.close()
Exemplo n.º 5
0
 def upSubStatus(self):
     config = {
         'host': 'host',
         'port': 3306,
         'user': '******',
         'passwd': 'pwd',
         'db': 'weCatch',
         'charset': 'utf8',
     }
     conn = mdb.connect(**config)
     lastTime = time.strftime('%Y-%m-%d')
     cursor = conn.cursor()
     try:
         sql = ("update subStatus SET status =1 ")
         cursor.execute(sql)
         conn.commit()
     except:
         import traceback
         traceback.print_exc()
         conn.rollback()
     finally:
         cursor.close()
         conn.close()