Skip to content

Instantly share code, notes, and snippets.

@meilechh
Created October 24, 2019 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meilechh/0d99527179dd167ae9af4903a81a9eb8 to your computer and use it in GitHub Desktop.
Save meilechh/0d99527179dd167ae9af4903a81a9eb8 to your computer and use it in GitHub Desktop.
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