oracle / python-cx_Oracle

Python interface to Oracle Database now superseded by python-oracledb
https://oracle.github.io/python-cx_Oracle
Other
890 stars 361 forks source link

Unable to execute "DESCRIBE ARADMIN.EPM_TechnicianInformation" in python jupyter notebook with cxOracle #584

Closed ebharti closed 3 years ago

ebharti commented 3 years ago

Hello, When I execute query "DESCRIBE ARADMIN.EPM_TechnicianInformation" like below: connection = cx_Oracle.connect(user=username, password=userpwd, dsn=dsn, encoding="UTF-8") cursor = connection.cursor() results = cursor.execute(" DESCRIBE ARADMIN.EPM_TechnicianInformation")

It is giving DatabaseError: ORA-00900: invalid SQL statement How can I create query "DESCRIBE ARADMIN.EPM_TechnicianInformation" with cx_Oracle? I want to get column details of the table.

Please help! Thanks!

sharadraju commented 3 years ago

This is a duplicate of Issue #198. The 'desc' command is a SQL*Plus command, not something the database or cx_Oracle understands.

Please check the documentation on cursor description property.

You can try the following:

# sql for column details
sql = "SELECT * from ARADMIN.EPM_TechnicianInformation"
cursor.execute(sql)
print(cursor.description)

This will print out the column description as a list, with each item referring to each column.