Guest User

Untitled

a guest
Mar 21st, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. import pymysql.cursors
  2. import numpy as np
  3. import time
  4.  
  5. connection = pymysql.connect(host='localhost',
  6. user='root',
  7. password='sql',
  8. db='test',
  9. charset='utf8mb4',
  10. cursorclass=pymysql.cursors.DictCursor)
  11.  
  12. try:
  13. with connection.cursor() as cursor:
  14. cursor.execute("truncate table test.histtest")
  15. for retry in range (0,300):
  16. for row in np.random.randn(100, 4):
  17. cursor.execute("insert into test.histtest values(null, %s, %s, %s, %s)", (str(row[0]),str(row[1]),str(row[2]),str(row[3])))
  18.  
  19. cursor.execute("delete from test.histtest where id = (select min(id) from test.histtest)")
  20. connection.commit()
  21. time.sleep(1)
  22.  
  23. finally:
  24. connection.close()
Add Comment
Please, Sign In to add comment