0

当我执行如下查询“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”?我想获取表格的列详细信息。

请帮忙!谢谢!

4

2 回答 2

1

' desc ' 命令是一个 SQL*Plus 命令,不是数据库或 cx_Oracle 理解的。

请查看有关 cx_Oracle的光标描述属性的文档。

您可以尝试以下方法:

# 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.
于 2021-09-13T11:09:52.143 回答
0

How to execute a SQL script with cx_oracle 中阅读,看起来 cx_Oracle 不理解 SQL Plus 特定语句

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

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

这也会在桌子上为您提供信息

于 2021-09-13T10:27:37.287 回答