Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

mysql insert into python many

sql = "INSERT INTO Student (Name, Roll_no) VALUES (%s, %s)"
val = [("Akash", "98"),
       ("Neel", "23"),
       ("Rohan", "43"),
       ("Amit", "87"),
       ("Anil", "45"), 
       ("Megha", "55"), 
       ("Sita", "95")]
  
mycursor.executemany(sql, val)
mydb.commit()
  
print(mycursor.rowcount, "details inserted")
  
# disconnecting from server
mydb.close()
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #mysql #insert #python
ADD COMMENT
Topic
Name
7+6 =