python mysql connection data table data into lookup table acquired in txt

pymysql Import 
'' 'is connected mysql table data into lookup table data acquired introduced in txt' ''
# write data to the query result txt
DEF get_loan_number (file_txt):
Connect = pymysql.Connect (
Host = "100.100.100.0",
Port = 3306,
User = "Test",
the passwd = "123",
DB = "with BigData",
charset = 'UTF8'
)
Print ( "writing, please wait ......")
Cursor = connect.cursor ()
SQL = "SELECT from ts_vehicle_load * "
the cursor.execute (SQL)
Number = cursor.fetchall ()
FP = Open (file_txt," W ")
loan_count = 0
for loanNumber in Number:
loan_count. 1 = +
FP.write(str(loanNumber) + "\n")
fp.close()
cursor.close()
connect.close()
print("写入完成,共写入%d条数据!" % loan_count)


if __name__ == "__main__":
file_txt = r"E:\Users\admin\PycharmProjects\untitled\d"
get_loan_number(file_txt)






Guess you like

Origin www.cnblogs.com/ymany/p/11009862.html