Sep-19-2019, 01:19 AM
Hi All,
I am beginner in Python, i am trying to access oracle DB from Python program. I am able to get the output with the below code. However, i want the SQL query which i ran along with the output. I am only getting the output. I tried 'set echo on' but its not working. Please help me.
I am beginner in Python, i am trying to access oracle DB from Python program. I am able to get the output with the below code. However, i want the SQL query which i ran along with the output. I am only getting the output. I tried 'set echo on' but its not working. Please help me.
#!/usr/bin/python ## Imports from subprocess import Popen, PIPE import os import sys sql1='set echo ON; \n select name from v$database;' sqlplus = Popen(["sqlplus", "-S", "/", "as", "sysdba"], stdout=PIPE, stdin=PIPE) sqlplus.stdin.write(sql1); out, err = sqlplus.communicate() print out
Output:Exexution Details:
===========
./test_db.py
NAME
---------
testdb