I created a table with 4 records. The table description is like: Employer
Now when I run the following piece of code:
import cx_Oracle
con = cx_Oracle.connect("system/******@localhost/xe")
cur = con.cursor()
cur.execute("SELECT * FROM Employer")
print(cur.fetchall())
print("\nNumber of rows fetched =",cur.rowcount)
print("\nDescription:",cur.description)`
The fetchall() fuction returns []. The rowcount is 0. But the description is correct, i.e. what it should be.
Description: [('COMPANYID', , 5, 5, 0, 0, 0), ('COMPANYNAME', , 50, 50, 0, 0, 0), ('EMAILID', , 30, 30, 0, 0, 1), ('MOBILE', , 11, 22, 10, 0, 1), ('CITY', , 15, 15, 0, 0, 1), ('INDUSTRYTYPE', , 20, 20, 0, 0, 1), ('FUNCTIONALAREA', , 20, 20, 0, 0, 1), ('MEMBERSHIPPLAN', , 20, 20, 0, 0, 1), ('DATEOFSIGNUP', , 23, 7, 0, 0, 1), ('DATEOFRENEWAL', , 23, 7, 0, 0, 1), ('RENEWALSTATUS', , 10, 10, 0, 0, 1)]
When I'm running the same query on the DB it runs fine. But here the fetchall() returns an empty tuple and the rowcount is 0. Please help. Thank you.
Believe it or not, you are not connected to the correct database and/or the table is truly empty. The description you get is inferred by the database and does not require the query to have any results.