Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymysql.cursors
- import numpy as np
- import time
- connection = pymysql.connect(host='localhost',
- user='root',
- password='sql',
- db='test',
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor)
- try:
- with connection.cursor() as cursor:
- cursor.execute("truncate table test.histtest")
- for retry in range (0,300):
- for row in np.random.randn(100, 4):
- cursor.execute("insert into test.histtest values(null, %s, %s, %s, %s)", (str(row[0]),str(row[1]),str(row[2]),str(row[3])))
- cursor.execute("delete from test.histtest where id = (select min(id) from test.histtest)")
- connection.commit()
- time.sleep(1)
- finally:
- connection.close()
Add Comment
Please, Sign In to add comment