From efb551011db5b71dcf3c7816bdf5083304900870 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Fri, 7 May 2021 00:16:49 +0200 Subject: [PATCH] Add Python/MySQL version --- dcb_python_mysql | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 dcb_python_mysql diff --git a/dcb_python_mysql b/dcb_python_mysql new file mode 100755 index 0000000..9813d6d --- /dev/null +++ b/dcb_python_mysql @@ -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")