Add Python/MySQL version

This commit is contained in:
Peter J. Holzer 2021-05-07 00:16:49 +02:00
parent 533855b188
commit efb551011d
1 changed files with 27 additions and 0 deletions

27
dcb_python_mysql Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/python3
import argparse
import time
ap = argparse.ArgumentParser()
ap.add_argument("--database")
ap.add_argument("--user")
ap.add_argument("--password")
args = ap.parse_args()
t0 = time.monotonic()
import mysql.connector
t1 = time.monotonic()
db = mysql.connector.connect(database=args.database, user=args.user, password=args.password)
t2 = time.monotonic()
csr = db.cursor()
csr.execute("select current_timestamp")
r = csr.fetchall()
t3 = time.monotonic()
db.close()
t4 = time.monotonic()
print(t1 - t0, "import")
print(t2 - t1, "connect")
print(t4 - t0, "total")
print(t4 - t1, "session")