1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| import mysql.connector
conn = mysql.connector.connect(host="localhost",
user="root", password="root",
database="projet")
cursor = conn.cursor()
file1 = open('test1.txt', "r")
test2=[]
for lines in file1:
test2.append(lines)
file1.close()
test3 = [x[0:-1] for x in test2]
print(test3)
for i in range(len(test3)):
print(test3[i])
reference = ('127.15.15',"rdfbg",1,2)
cursor.execute("INSERT INTO "+ test3[i] + "(IP,status,time,total_time) VALUES(%s, %s, %s, %s)", reference)
conn.commit()
conn.close() |
Partager