database_connect_bench/dcb_python_oracle

28 lines
573 B
Plaintext
Raw Normal View History

2021-05-07 23:09:11 +02:00
#!/usr/bin/env python3
import argparse
import time
ap = argparse.ArgumentParser()
ap.add_argument("--user")
ap.add_argument("--password")
args = ap.parse_args()
t0 = time.monotonic()
import cx_Oracle
t1 = time.monotonic()
db = cx_Oracle.connect(f"{args.user}/{args.password}@localhost/XEPDB1")
t2 = time.monotonic()
csr = db.cursor()
csr.execute("select current_timestamp from dual")
r = csr.fetchall()
print(r)
t3 = time.monotonic()
db.close()
t4 = time.monotonic()
print(t1 - t0, "import")
print(t2 - t1, "connect")
print(t4 - t0, "total")
print(t4 - t1, "session")