Jmeter do performance testing, we need to read the data order number
Copy the files from the database query to the trouble;
Read from the database directly using JDBC, about the effects on actual test results, it is necessary to copy the data to a file manually
python code to achieve:
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))