【问题标题】:cx_Oracle.DatabaseError: ORA-00933: SQL command not properly endedcx_Oracle.DatabaseError: ORA-00933: SQL 命令未正确结束
【发布时间】:2020-09-04 14:14:29
【问题描述】:

我在尝试运行以下代码时收到错误 cx_Oracle.DatabaseError: ORA-00933: SQL command not properly ended。我用过

import cx_Oracle
ip = '127.0.0.1'
port = 1234
SID = 'abcd'
dsn_tns = cx_Oracle.makedsn(ip, port, SID)

conn = cx_Oracle.connect('username', 'password', dsn_tns)
curs = conn.cursor()
curs.execute('select sysdate from dual;')  # Error is here
curs.close()
conn.close()

按预期运行以下工作:

conn = cx_Oracle.connect('username', 'password', dsn_tns)
print (conn.version)
conn.close()

【问题讨论】:

  • 我认为您不需要查询末尾的分号,也许它与此有关
  • @Duikboot,你是对的。做出回答,我会接受的。
  • 解释一下:分号用于命令行工具告诉他们你不会输入另一行 SQL,因此告诉这些工具将所有前面的文本发送到数据库用于加工,。数据库需要一个没有尾随分号的 SQL 语句。

标签: python cx-oracle


【解决方案1】:

你不需要查询末尾的分号,也许它与它有关

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-09
    • 2010-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多