Python
0
Вклад в тег
def unpack_csv(line):
csv = line.split(";")
csv_1 = csv[0]
csv_2 = csv[1]
...
return csv_1, csv_2, csv_3, csv_4, csv_5
db = pymysql.connect(host='', user='', passwd='', db='', charset='utf8')
cursor = db.cursor()
file = open('test.csv', 'r')
for line in file:
number, date, fio, email, about = unpack_csv(line)
sql = """INSERT INTO mydb(number, date, fio, email, about)
VALUES ('%s','%s', '%s', '%s', '%s')
""", (number, date, fio, email, about)
cursor.execute(sql)
db.commit()
db.close()
file.close()