-
-
Save swiatczak/a5f151098f7c8720d430e238ed0b8a5c to your computer and use it in GitHub Desktop.
Get Oracle DBMS_Output from Python's cx_Oracle library
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
| import cx_Oracle | |
| conn = cx_Oracle.Connection("userid/password@tns") | |
| curs = conn.cursor() | |
| curs.callproc("dbms_output.enable") | |
| sqlCode = """ | |
| some long | |
| sql code | |
| with dbms_output | |
| """ | |
| curs.execute(sqlCode) | |
| statusVar = curs.var(cx_Oracle.NUMBER) | |
| lineVar = curs.var(cx_Oracle.STRING) | |
| while True: | |
| curs.callproc("dbms_output.get_line", (lineVar, statusVar)) | |
| if statusVar.getvalue() != 0: | |
| break | |
| print lineVar.getvalue() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment