Home > Net >  cx Oracle not showing query results
cx Oracle not showing query results

Time:12-03

This connection works, but the result is just the text of the query itself:

Connection = cx_Oracle.connect(user=username, password=password, dsn=dsn, encoding=enc)

query = 'simple select statement'

cursor = Connection.cursor()
cursor.execute(query)
Connection.commit()
cursor.close()

print(query)

The result in the dataframe prints 'SELECT RECV_MBR_ID...' instead of the ID's. What am I missing?

CodePudding user response:

This is not unexpected! You are simply printing the value to which you set that variable! You need to fetch the results. You can do this in one of several ways. I'll show a couple of the more common ones here:

for row in cursor.execute(query):
    print(row)

OR

cursor.execute(query)
print(cursor.fetchall())
  • Related