无法使用 cx_Oracle 在 python jupyter notebook 中执行 "DESCRIBE ARADMIN.EPM_TechnicianInformation"

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

当我执行如下查询“DESCRIBE ARADMIN.EPM_TechnicianInformation”时:

connection = cx_Oracle.connect(user=username, password=userpwd, dsn=dsn, encoding="UTF-8")
cursor = connection.cursor()
results = cursor.execute(" DESCRIBE ARADMIN.EPM_TechnicianInformation")

它正在给予

DatabaseError: ORA-00900: invalid SQL statement

如何使用 cx_Oracle 创建查询“DESCRIBE ARADMIN.EPM_TechnicianInformation”? 我想获取 table.

的列详细信息

请帮忙!谢谢!

读到的 SQL 再加上 cx_Oracle

不理解特定语句

您可以通过以下方式尝试获取所需的信息:

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

这也会为您提供有关 table 的信息

desc”命令是一个 SQL*Plus 命令,数据库或 cx_Oracle 无法理解。

请查看 cx_Oracle description 属性 游标的文档。

您可以尝试以下方法:

# 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.