INNER CODE UNIT · Python
InsertStress
bitpoke/mysql-operator · hack/development/stress_test.py:43
class InsertStress(Base):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.table_name = 'test'
def init_sql(self):
cursor = self.db.cursor()
cursor.execute('CREATE TABLE IF NOT EXISTS {} '
'(f1 VARCHAR(30), f2 VARCHAR(30), f3 VARCHAR(30))'.format(self.table_name))
self.db.commit()
def test(self, epoch):
sql = "INSERT INTO {} (f1, f2, f3) VALUES (%s, %s, %s)".format(self.table_name)
val = []
for i in range(self.args.rows):
val.append(("l_"+str(i), "f_"+str(i), "a_"+str(i)))