Hi All,
I have below script which runs ok without any errors but does not give me any output.
My task is to be able to run a sql query from python script and then use the result to prepare a xml file.
As the first step I am trying to build Python to extract query data for me, but below script not giving any output even when I have ~40 rows in table.
I would like to connect to Sqlplus through cx_Oracle library.
import cx_Oracle
import sys try:
# First, create a DB connection:
connection = cx_Oracle.Connection('UserName' + '/' + 'password' + '@' + 'DatabaseName')
# Next, obtain a cursor:
cursor = connection.cursor()
# Now we can execute SQL code via our cursor:
cursor.execute('select * from table')
# And fetch query results one by one:
for i in range(cursor.rowcount):
row = cursor.fetchone()
print row[1]
cursor.close()
except
cx_Oracle.DatabaseError, exc: print >> sys.stderr, "Oracle-Error:", str(exc)
Please help me to find what is wrong in this script?
Thanks.