# 将bsp返回的xml转化成json格式
xml2json = xmltodict.parse(response.text)
json_str = json.dumps(xml2json,indent=1)
ss = json.loads(json_str)
# 加密成md5
hl = hashlib.md5()
hl.update(to_be_md5_data.encode(encoding='utf-8'))
content = hl.digest()
result = base64.b64encode(content).decode('utf-8')
def IntoMysql(self):
mysql_host ='100.80.162.219'
mysql_db ='dmp'
mysql_user ='dmp'
mysql_password ='#Wnv#ayfHU'
mysql_port =3306
db = pymysql.connect(host=mysql_host, port=mysql_port, user=mysql_user, password=mysql_password, db=mysql_db,
charset='utf8')# 连接数据库编码注意是utf8,不然中文结果输出会乱码
cursor = db.cursor()
name_list,score_list =self.get_data()
i =0
for jin name_list:
accname=j+str(random.randint(999,10000))
usercode =score_list[i]+str(random.randint(999,10000))
i+=1
sql="INSERT INTO sys_user(user_code,account_name,PASSWORD,user_name,work_number,phone,monthly_number,delete_flag,mark,creator_id,super_flag) VALUES('%s','%s','$2a$10$QPjRhJK4ferPBLX9o1UAp.7kGBkSU.Sb85ah/z4N0L8FIe08pWw4e','周星驰','123','UVGXJ4AEBrqr0VSyGbwnWw==','ORu48GS3/09m7ZWmOzJ0Gw==','1','5555','1','0');" %(usercode,accname)
try:
# 执行sql语句
cursor.execute(sql)
# 提交到数据库执行
db.commit()
except Exception as e:
# Rollback in case there is any error
db.rollback()
# 关闭数据库连接
db.close()