如何获取DDL命令的输出python cx_oracle
我目前正在与CX_oracle一起
使用SELECT语句,我可以使用fetchall()函数来获取行。
但是如何获取属于数据定义语言(DDL)类别的查询的输出。
例如,在使用Cursor.execute()执行赠款语句之后,假设查询有效的预期输出将是
“成功执行的授予”
,但是我如何使用cx_oracle,python获得此信息。
I am currently working with cx_oracle
Here with SELECT statements I am able to use the fetchall() function to get rows.
But how to get the outputs for queries that fall under Data Definition Language (DDL) category.
For example, after executing a GRANT statement with cursor.execute(), the expected output assuming the query is valid would be,
"GRANT executed successfully"
But how do I get this with cx_oracle, Python.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是您自己打印了,这就是SQL*Plus的作用。
DDL语句是语句而不是查询,因为它们不返回数据。他们将成功或错误条件归还执行它们的工具,然后可以打印任何消息。在您的情况下,该工具是cx_oracle。没有办法在CX_oracle中自动获取语句的类型(授予,创建等)。您的应用程序可以打印一条通用消息,例如“成功执行的语句”,也可以从SQL语句中提取第一个关键字,因此您可以打印像SQL*Plus这样的消息。
The answer is that you have print it yourself, which is what SQL*Plus does.
DDL statements are statements not queries because they do not return data. They return a success or error condition to the tool that executed them, which can then print any message. In your case the tool is cx_Oracle. There isn't a way to get the type (GRANT, CREATE etc) of the statement automatically in cx_Oracle. Your application can either print a generic message like 'statement executed successfully', or you can extract the first keyword(s) from the SQL statement so you can print a message like SQL*Plus does.