1.
import time import pymysql import pandas as pd from datetime import datetime,timedelta
2.
cuor = pymysql.connect(host = "", user = "", password = "", db = "<库名>")
3.
cur = cuor.cursor()
4.
ucol = "record_id pay_channel pay_config_key biz_scenario biz_serial_no pay_amount pay_description response_time pay_status stage user_id our_trans_number third_trans_number receipt create_time update_time".replace(" ",",") sql1 = "select {0} ".format(ucol) sql2 = "from mall_pay_record " sql3 = "limit 10" ec = cur.execute(sql1+sql2+sql3) # print(ec) ecfe = cur.fetchall() # print(ecfe)
5.
ecpd = pd.DataFrame(ecfe,columns=ucol.split(‘,‘)) ecpd.head()
6.