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!

2

There are 2 best solutions below

0
On BEST ANSWER

The 'desc' command is a SQL*Plus command, not something the database or cx_Oracle understands.

Please check the documentation on cursor description property of cx_Oracle.

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.
3
On

reading from How to execute a SQL script with cx_oracle it looks like SQL Plus specific statements are not understood by cx_Oracle

you can try getting the information you need by doing :

SELECT * FROM ALL_TABLES WHERE OWNER= 'ARADMIN' AND TABLE_NAME = 'EPM_TechnicianInformation'

This will give you infos on the table as well