标签:性能测试 手机号 phone edit http 数据 result HERE left join
Jmeter做性能测试中,需要读取订单号的数据
从数据库中查询复制到文件中麻烦了;
直接用JDBC从数据库中读取,担心会影响实际测试结果,因此需要把数据手动复制到文件中
python代码的实现:
import selenium import requests import json from lxml import html # from sgmllib import SGMLParser from lxml import etree import pymysql import mysql_ok phones=1591038300 filename=‘888mysql_yx.txt‘ ‘‘‘ 从数据库中取数据写到本地文件中 ‘‘‘ mydb = pymysql.connect(host="10.253.125.188", port=3306, user="root", passwd="sjroot", db="user", charset=‘utf8‘) mycursor = mydb.cursor() ‘‘‘查询手机号码‘‘‘ # sql = "SELECT phone_tel FROM user.t_user_info where phone_tel like ‘%{}%‘;".format(phones) ‘‘‘查询用户id‘‘‘ # sql = "SELECT t.id,t.phone_tel FROM user.t_user_info t where t.phone_tel like ‘%{}%‘;".format(phones) ‘‘‘查询授信订单号‘‘‘ sql = "SELECT a.app_id FROM bill_data.t_org_br_credit_info a left join user.t_user_info b on a.user_id=b.id " "where a.user_id in (SELECT id FROM user.t_user_info t where " "t.phone_tel like ‘%{}%‘ ) " "order by phone_tel ASC;".format(phones) ‘‘‘查询用信订单号‘‘‘ mycursor.execute(sql) myresult =mycursor.fetchall() fp = open(‘E:\\apache-jmeter-4.0\\test\\ziyingfiles\\{}‘.format(filename),‘w‘) num_count=0 for x in myresult: num_count+=1 print(‘phone_tel:‘, x[0], type(x)) fp.write(x[0] + "\n") fp.close() mycursor.close() mydb.close() print(‘写入完成,共写入{0}条数据‘.format(num_count))
标签:性能测试 手机号 phone edit http 数据 result HERE left join
原文地址:https://www.cnblogs.com/jpr-ok/p/11948905.html