mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-08-04 08:04:45 +00:00

Fixed various coding style stuff detected by flake8. Added .pre-commit-config.yaml: With command pre_commit install a hook for flake8 will be installed.
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
#!/usr/bin/env python3 -O
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import pyperf
|
|
|
|
|
|
def bulk(loops, conn, paramstyle):
|
|
cursor = conn.cursor()
|
|
cursor.execute("CREATE TEMPORARY TABLE test_update_bulk ("
|
|
"a int primary key, b int)")
|
|
# conn.autocommit= False
|
|
t0 = pyperf.perf_counter()
|
|
vals = [(i,) for i in range(10000)]
|
|
range_it = range(loops)
|
|
for value in range_it:
|
|
if paramstyle == 'qmark':
|
|
cursor.executemany("INSERT INTO test_update_bulk VALUES (?,NULL)",
|
|
vals)
|
|
conn.commit()
|
|
cursor.executemany("UPDATE test_update_bulk SET b=2 WHERE a=?",
|
|
vals)
|
|
conn.commit()
|
|
cursor.executemany("DELETE FROM test_update_bulk WHERE a=?",
|
|
vals)
|
|
else:
|
|
cursor.executemany("INSERT INTO test_update_bulk VALUES (%s,NULL)",
|
|
vals)
|
|
conn.commit()
|
|
cursor.executemany("UPDATE test_update_bulk SET b=2 WHERE a=%s",
|
|
vals)
|
|
conn.commit()
|
|
cursor.executemany("DELETE FROM test_update_bulk WHERE a=%s",
|
|
vals)
|
|
conn.commit()
|
|
cursor.execute("DROP TABLE IF EXISTS test_update_bulk")
|
|
del cursor
|
|
return pyperf.perf_counter() - t0
|