Created
April 18, 2018 18:09
-
-
Save Roguelazer/79e0eac7d3361cca25d00b12dee9932a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import MySQLdb | |
import time | |
def main(): | |
parser = argparse.ArgumentParser() | |
args = parser.parse_args() | |
conn = MySQLdb.connect(db='ghtest') | |
cursor = conn.cursor() | |
cursor.execute('DROP TABLE IF EXISTS ghtest') | |
cursor.execute('DROP TABLE IF EXISTS _ghtest_gho') | |
cursor.execute('DROP TABLE IF EXISTS _ghtest_del') | |
cursor.execute('CREATE TABLE ghtest (id BIGINT AUTO_INCREMENT PRIMARY KEY, to_drop INT DEFAULT NULL, value MEDIUMTEXT DEFAULT NULL, other_field BOOLEAN DEFAULT FALSE, always_null INT DEFAULT NULL)') | |
for i in range(102400): | |
cursor.execute('INSERT INTO ghtest(value) VALUES(%s)', (str(i),)) | |
print('created, will do insertions and updates for next 30s') | |
start = time.time() | |
while time.time() - start < 30: | |
conn.begin() | |
cursor.execute('INSERT INTO ghtest(value, other_field) VALUES (%s, %s)', (str(i), False)) | |
pk = cursor.lastrowid | |
conn.commit() | |
conn.begin() | |
cursor.execute('UPDATE ghtest SET other_field=%s WHERE id=%s', (True, pk)) | |
conn.commit() | |
print('done') | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment