Esempio n. 1
0
    def addUrl(self, data):
        sql = simpleToolSql("url")
        res = self.getListFromSql(data['url'])
        if len(res) > 0:
            return
        # print(res)
        # return

        res = sql.execute(
            "insert into zh_article (url,title,archive,folder,type,msgid,created,updated,state,create_at,update_at) values (?,?,?,?,?,?,?,?,?,?,?);",
            [(
                data['url'],
                data['title'],
                data['archive'],
                data['folder'],
                data['type'],
                data['msgid'],
                data['created'],
                data['updated'],
                data['state'] if data.__contains__('state') else 0,
                time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
                time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
            )]
        )
        print(res)
        sql.close()
        return
Esempio n. 2
0
 def getListFromSql(self, url):
     sql = simpleToolSql("url")
     # res = sql.query("select * from zh_article where state=0;")
     res = sql.query("select * from zh_article where url='" + url + "';")
     # print(res)
     sql.close()
     return res
Esempio n. 3
0
 def getAblums(self):
     sql = simpleToolSql("url")
     res = sql.query("select * from zh_ablum where update_at<'{t}';".format(
         t=(datetime.datetime.now() - datetime.timedelta(hours=72)).strftime("%Y-%m-%d %H:%M:%S")))
     # print(res)
     sql.close()
     return res
Esempio n. 4
0
 def updateUrlState(self, id: int):
     sql = simpleToolSql("url")
     res = sql.execute("update zh_article set state=1 where id = ?;", (id,))
     # 需要加逗号 https://blog.csdn.net/yimaoyingbi/article/details/104323701
     print(res)
     sql.close()
     return
Esempio n. 5
0
def getListFromSql():
    sql = simpleToolSql("url")
    # res = sql.query("select * from wx_article where state=0;")
    res = sql.query("select * from wx_article;")
    print(res)
    sql.close()
    return res
Esempio n. 6
0
 def getListFromParam(self, paramsql):
     sql = simpleToolSql("url")
     # res = sql.query("select * from zh_article where state=0;")
     res, res_name = sql.queryall("select * from zh_article where " +
                                  paramsql + ";")
     # print(res)
     sql.close()
     return res, res_name
Esempio n. 7
0
 def getAblumListFromSql(self, url):
     sql = simpleToolSql("url")
     # res = sql.query("select * from zh_article where state=0;")
     res = sql.query("select * from zh_ablum where url='{u}' and update_at<'{t}';".format(u=url, t=(
         datetime.datetime.now() - datetime.timedelta(hours=72)).strftime("%Y-%m-%d %H:%M:%S")))
     # print(res)
     sql.close()
     return res
Esempio n. 8
0
 def updateAblum(self, id):
     sql = simpleToolSql("url")
     # res = sql.query("select * from zh_article where state=0;")
     # print("-*-*-*-*")
     res = sql.execute("update zh_ablum set update_at='{t}' where id={id};".format(
         t=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), id=id))
     print("更新===", res)
     sql.close()
     return res
Esempio n. 9
0
def addUrl():
    sql = simpleToolSql("url")
    sql.execute(
        "insert into wx_article (url,folder,title,state,turn,create_at,update_at) values (?,?,?,?,?,?);",
        [("http", 'test', "01", 0, 1, "2020-12-03 09:38:25",
          "2020-12-03 09:38:25")])
    res = sql.query("select * from wx_article;")
    print(res)
    sql.close()
    return
Esempio n. 10
0
 def updateUrlState(self, id: int):
     sql = simpleToolSql("url")
     res = sql.execute(
         "update wx_article set state=1,update_at=? where id = ?;", (
             time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
             id,
         ))
     # 需要加逗号 https://blog.csdn.net/yimaoyingbi/article/details/104323701
     print(res)
     sql.close()
     return
Esempio n. 11
0
 def getAblumListFromAuthorAndTitle(self, title):
     sql = simpleToolSql("url")
     # res = sql.query("select * from zh_article where state=0;")
     res = sql.query(
         "select * from zh_ablum where title='{ti}' and update_at<'{t}';".
         format(
             ti=title,
             t=(datetime.datetime.now() -
                datetime.timedelta(hours=2)).strftime("%Y-%m-%d %H:%M:%S")))
     # print(res)
     sql.close()
     return res
Esempio n. 12
0
 def getListFromSql(self, title):
     sql = simpleToolSql("url")
     # res = sql.query("select * from wx_article where state=0;")
     # print(colored("++--+++---++","yellow"), title)
     if title.find("'") > -1:
         str = 'select * from wx_article where title="' + title + '";'
     else:
         str = "select * from wx_article where title='" + title + "';"
     # res = sql.query("select * from wx_article where title='" + title + "';")
     res = sql.query(str)
     sql.close()
     return res
Esempio n. 13
0
    def addAblum(self, url, author, title):
        sql = simpleToolSql("url")
        res = self.getAblumListFromAuthorAndTitle(title)
        print(res)
        # return
        if len(res) > 0:
            self.updateAblum(res[0][0])
            print(res[0][0])
            return

        res = sql.execute(
            "insert into zh_ablum (url,author,title,create_at,update_at) values (?,?,?,?,?);",
            [(url, author, title,
              time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
              time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))])
        print(res)
        sql.close()
        return
Esempio n. 14
0
    def addUrl(self, data):
        sql = simpleToolSql("url")
        res = self.getListFromSql(data['title'])
        if len(res) > 0:
            return
        # print(res)
        # return

        res = sql.execute(
            "insert into wx_article (url,folder,title,state,msgid,turn,create_at,update_at) values (?,?,?,?,?,?,?,?);",
            [(data['link'], data['folder'].replace(
                ' ', ''), data['title'], 0, data['msgid'], data['turn'],
              time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
              time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))])
        print(colored("--->---->--->", "red"),
              colored(data['title'], "red", "on_white"), res)
        sql.close()
        return
Esempio n. 15
0
    def addAblum(self, url, author, title):
        sql = simpleToolSql("url")
        res = self.getAblumListFromSql(url)
        # print(res)
        # return
        if len(res) > 0:
            self.updateAblum(res[0][0])
            print(res[0][0])
            return

        res = sql.execute(
            "insert into wx_ablum (url,author,title,create_at,update_at) values (?,?,?,?,?);",
            [(url, author, title,
              time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
              time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))])
        print(colored("写入集合=====", "green"), colored(author, "yellow"),
              colored(title, "red"))
        sql.close()
        return
Esempio n. 16
0
 def getListByTitle(self, title: str):
     sql = simpleToolSql("url")
     res = sql.query("select * from zh_article where title=" + title + ";")
     print(res)
     sql.close()
     return res