Thank you so much for the methods and i come with a new question:
i want to build an insert query for each match from that file and then send it to my own database..
for example from
Verona - Napoli
10.42% (9.60) 1.11% 1
27.08% (3.69) 11.11% X
62.5% (1.60) -11.11% 2
37.5% (2.67) 11.11% 1X
89.58% (1.12) -1.11% X2
72.92% (1.37) -11.11% 12
create the query
INSERT INTO sbostats (partita,p1,pX,p2,p1x,px2,p12) VALUES ("Verona - Napoli","10.42% (9.60) 1.11% 1" ,"27.08% (3.69) 11.11% X ","62.5% (1.60) -11.11% 2 ","37.5% (2.67) 11.11% 1X " ," 89.58% (1.12) -1.11% X2"," 72.92% (1.37) -11.11% 12 " );
and so on...
i have to take the number of rows of file and then do same from line 1 to 7 than 8 to 14 and so on?
so i have to put datas in "val" and iterate.. but i have no idea how to do that!
i want to build an insert query for each match from that file and then send it to my own database..
for example from
Verona - Napoli
10.42% (9.60) 1.11% 1
27.08% (3.69) 11.11% X
62.5% (1.60) -11.11% 2
37.5% (2.67) 11.11% 1X
89.58% (1.12) -1.11% X2
72.92% (1.37) -11.11% 12
create the query
INSERT INTO sbostats (partita,p1,pX,p2,p1x,px2,p12) VALUES ("Verona - Napoli","10.42% (9.60) 1.11% 1" ,"27.08% (3.69) 11.11% X ","62.5% (1.60) -11.11% 2 ","37.5% (2.67) 11.11% 1X " ," 89.58% (1.12) -1.11% X2"," 72.92% (1.37) -11.11% 12 " );
and so on...
i have to take the number of rows of file and then do same from line 1 to 7 than 8 to 14 and so on?
import mysql.connector from mysql.connector import errorcode mydb = mysql.connector.connect( host="localhost", user="root", database="my_db" ) mycursor = mydb.cursor() sql = "INSERT INTO sbostats (partita,p1,pX,p2,p1x,px2,p12) VALUES (%s, %s,%s, %s,%s, %s, %s)" val = ("test1", "test2","3", "4", "5", "6", "7") mycursor.execute(sql, val) mydb.commit() print(mycursor.rowcount, "record inserted.")i saw also that i can connect to my database :) and i can send the query .. All was fine
so i have to put datas in "val" and iterate.. but i have no idea how to do that!