You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
731 B

import pymysql
from pymysql.cursors import DictCursor
from config import db_config
class Result:
def __init__(self):
self.db_conn = pymysql.connect(**db_config)
self.cursor = self.db_conn.cursor(cursor=DictCursor)
def save(self, data):
try:
self.cursor.execute(
"INSERT INTO result (api, case_id, xml_req_params, xml_resp_xml, xml_resp_json, xml_resp_format, json_req_params, json_req_data, json_req_json, compare_result) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
data)
self.db_conn.commit()
except Exception as e:
print('save_result', e)
def close_db(self):
self.cursor.close()
self.db_conn.close()