From 4a53bf76f389ee2d8416df0cab82ea4ef5b657d4 Mon Sep 17 00:00:00 2001 From: Josue Gomez Date: Thu, 28 Mar 2019 13:05:29 -0600 Subject: [PATCH] dbmsoutput --- oracle.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/oracle.py b/oracle.py index a609622..a27a936 100644 --- a/oracle.py +++ b/oracle.py @@ -2,10 +2,27 @@ import cx_Oracle APP_CTX_NAMESPACE = "USERENV" APP_CTX_ENTRIES = [ - ( APP_CTX_NAMESPACE, "MODULE", "modulo prueba"), + (APP_CTX_NAMESPACE, "MODULE", "modulo prueba"), ] +def dbmsoutput(cursor): + """ + dbmsoutput must be enabled before execute statement + cur.callproc("dbms_output.enable",(None,)) + """ + output = str() + status = cursor.var(cx_Oracle.NUMBER) + dbmsline = cursor.var(cx_Oracle.STRING) + while True: + cursor.callproc("dbms_output.get_line", (dbmsline, status)) + if status.getvalue(): + break + output += f'{dbmsline.getvalue()} \n' + + return output + + class OraConn(cx_Oracle.Connection): # instance can return a cursor or the whole conn def __init__(self, str_conn, ret="conn", module_name=None):