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()
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)
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))
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
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()