Python Forum

Full Version: Best way to return Cursor Data
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am very new to python.

--This method is encapsulated in class OracleQuery :
def executeProcedure(self, query):
try:
oracleConnectionRef = OracleConnection(self._host, self._port, self._serviceName, self._schemaUser, self._schemaPassword)
oracleConn = oracleConnectionRef.createConnection()
if oracleConn is None :
print("Connection failed to open..")
return None
else:
cur = oracleConn.cursor()
refCursorVar = cur.var(cx_Oracle.CURSOR)
cur.callproc(query, [14032, refCursorVar] )
return refCursorVar.getvalue()
except Exception as e:
print("Exception: " + str(e))

I want to write a module that will be able to run Oracle Queries( Packages, Functions, Stored Prcoedures) . What the best way to return the results of a ref Cursor. it should contain both the column definition / rows data for external clients to consume it.

Problem is if i return the cursor i am unable to iterate it because its closed.