python3 load data infile for mysql5.7

def load():
global myConn
sql = "truncate table test"
myConn.execute(sql)
print('truncate table success')

# 加参数也可 character set gbk
# 换行键: ==x0A==chr(10),ord('字符')==数字,chr(数字)=字符
# 标题开始:^A==x01==chr(1)
# 双引号: "==x22==chr(34)
    sql = """load data infile '/home/ccx/test.txt' into table test 
fields terminated by ',' enclosed by 'x22' lines terminated by 'x0A'"""
myConn.execute(sql)
print('load data infile success')
原文地址:https://www.cnblogs.com/zsfishman/p/11663807.html