Exemplo n.º 1
0
 def insert_into_data(self,sql):
         try:
             cour=self.con.cursor()
             cour.execute(sql)
             logger.info("更新成功")
             self.con.commit()
         except pymysql.MySQLError as error:
             logger.info("错误信息为{}".format(error))
             self.con.rollback()
Exemplo n.º 2
0
    def check_all(self,sql):
        try:
            with self.con.cursor() as cur:
                cur.execute(sql)
                logger.info("查询successful")
                # self.con.commit()
                return cur.fetchall()

        except pymysql.MySQLError as error:
            print(error)
Exemplo n.º 3
0
    def res(self, request, body, *args, **kwargs):
        logger.info("你输入的请求为{}".format(request))
        if request.lower() == "get":

            res = self.re_get(*args, **kwargs)
            return res
        elif request.lower() == "post":
            res = self.re_post(body, *args, **kwargs)
            return res
        else:
            # return '你输入请求error{}'.format(request)
            logger.info('该版本没有您输入这种请求的处理方法{}'.format(request))
Exemplo n.º 4
0
 def test_login(self, test_info):
     # msg="O"
     url = "http://120.78.128.25:8766/futureloan"
     c = Inter().login(url=url + test_info["test_url"],
                       body=eval(test_info["test_data"]),
                       headers=eval(test_info["test_header"]))
     logger.info(test_info["test_data"])
     try:
         self.assertEqual(test_info["test_except"], c["msg"])
     except AssertionError as error:
         print(error)
         raise error
Exemplo n.º 5
0
 def check(self,sql):
     try:
         with self.con.cursor() as cur :
             res = cur.execute(sql)
             if res ==1:
                 logger.info("查询successful")
                 return cur.fetchone()
             self.con.commit()
     except pymysql.MySQLError as error:
         logger.info("错误信息为{}".format(error))
         # 回滚
         self.con.rollback()
     self.con.cursor().close()
     self.con.close()