Created
October 24, 2019 20:16
-
-
Save meilechh/0d99527179dd167ae9af4903a81a9eb8 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
from __future__ import print_function | |
import random | |
from copy import copy | |
import time | |
import sys | |
import cx_Oracle | |
userName=sys.argv[1] | |
password=sys.argv[2] | |
connectionString=sys.argv[3] | |
connection = cx_Oracle.connect(userName, password, connectionString) | |
connection.stmtcachesize = 500 | |
cursor = connection.cursor() | |
users=[{'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}, {'lastName': 'A'}] | |
subQuery="SELECT :last_name0 AS last_name FROM dual" | |
for x in range(1, 30): | |
subQuery=subQuery + " UNION SELECT :last_name{} AS last_name FROM dual".format(x,x) | |
query="""SELECT 'blahhh' FROM dual WHERE dummy IN ({subQuery}) """.format(subQuery = subQuery) | |
for j in range(100): | |
#cursor = connection.cursor() | |
for x, u in enumerate(users): | |
copyOfList=copy(users) | |
random.shuffle(copyOfList) | |
randomNumber=random.randint(1,19) | |
partialUsers=copyOfList[0:randomNumber] | |
binds={} | |
for i,user in enumerate(partialUsers): | |
binds.update({'last_name'+str(i): user["lastName"]}) | |
for i in range(randomNumber, 30): | |
binds.update({'last_name'+str(i): "DUMMY"}) | |
try: | |
rows = cursor.execute(query, binds) | |
except cx_Oracle.DatabaseError as exc: | |
error, = exc.args | |
print("An exception occurred running query", error.message) | |
print("Finished running query {}'th time".format((j*len(users))+(x+1))) | |
#cursor.close() | |
time.sleep(j* 10) | |
connection.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment