Created
March 12, 2018 21:49
-
-
Save marktriggs/d68db4a6fe76e39d693151093317839d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 mysql.connector | |
import uuid | |
import time | |
def do_some_writes(conn, rowcount, autocommit=True): | |
add_row = ("INSERT INTO mark (s) values (%s)"); | |
cursor = conn.cursor() | |
for _ in xrange(rowcount): | |
cursor.execute(add_row, (str(uuid.uuid4()),)) | |
if autocommit: | |
conn.commit() | |
conn.commit() | |
cursor.close() | |
if __name__ == '__main__': | |
rowcount = 1000 | |
conn = mysql.connector.connect(user="root", password="12345", host="mysql", database="marktesting") | |
for autocommit in [True, False]: | |
start_time = time.time() | |
do_some_writes(conn, rowcount, autocommit=autocommit) | |
end_time = time.time() | |
print "Time to insert %d rows with autocommit = %s: %f" % (rowcount, autocommit, end_time - start_time) | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment