Guest User

Untitled

a guest
Jul 14th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. import mysql.connector
  2.  
  3. insert_sql = ("INSERT INTO table (Value) VALUES (%s)")
  4.  
  5. for i in range(100):
  6. cnx = mysql.iconnector.connect(user='root', password='password', host='127.0.0.1', database='database')
  7. cursor = cnx.cursor()
  8. # Insert 50000 rows here
  9. for j in range(50000):
  10. cursor.execute(insert_sql, (j,))
  11. cnx.commit()
  12. cursor.close()
  13. cnx.close()
  14. print('Finished processing one file')
  15.  
  16. print('All done')
  17.  
  18. CREATE TABLE `table` (
  19. `Id` int(11) NOT NULL AUTO_INCREMENT,
  20. `Value` int(11) NOT NULL,
  21. PRIMARY KEY (`EventId`)
  22. )
Add Comment
Please, Sign In to add comment