python – cx_Oracle:错误933. ORA-00933:“SQL命令未正确结束”:SQL命令错误?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python – cx_Oracle:错误933. ORA-00933:“SQL命令未正确结束”:SQL命令错误?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1951字,纯文字阅读大概需要3分钟。
内容图文
![python – cx_Oracle:错误933. ORA-00933:“SQL命令未正确结束”:SQL命令错误?](/upload/InfoBanner/zyjiaocheng/906/649d47095f2141df895af6c85b55ed1a.jpg)
之前已经提出了类似的问题,但我仍然无法找到解决方案.我的代码:
try:
connection = cx_Oracle.connect(ORACLE_CONNECT)
logger.info("Connection to Oracle success.")
print ("Oracle DB version: " + connection.version)
print ("Oracle client encoding: " + connection.encoding)
print ("Python version: " + platform.python_version())
except cx_Oracle.DatabaseError as e:
error, = e.args
if error.code == 1017:
print ("Username/password invalid.")
logger.debug("Username/password invalid: %s", error.code)
else:
logger.debug("Database connection error: %s", e)
print ("Database connection error: %s".format(e))
raise
cursor = connection.cursor()
smsreport_text_new = tuple(smsreport_text)
find_command = self.identify_unique_msgid(smsreport_list)
cursor.execute(find_command)
def identify_unique_msgid(self, smsreport_list):
msgid_i_to_be_crosschecked = smsreport_list.get('msgid_i')
msgid_ii_to_be_crosschecked = smsreport_list.get('msgid_ii')
find_command = 'SELECT * FROM myTable WHERE msgid_i = {0}'.format(msgid_i_to_be_crosschecked)
print (find_command)
return find_command
find_command看起来像这样:
SELECT * FROM myTable WHERE msgid_i = 2R67C865FB6ZHG5A9
我在SQL查询结束时尝试使用和不使用分号,但仍然失败.我知道连接有效,因为我有另一个查询(见下文),这会将数据写入表中.只是在尝试查找包含某些值的行时,我收到此错误消息.
insert into xura_push (date_sms, result_sms, msgid, msgparts, msgid_i, msgid_ii) values (TO_DATE(:1, 'dd-mon-yyyy hh24:mi:ss'), :2, :3, :4, :5, :6)
我哪里错了?
干杯,pymat.
解决方法:
如上面的评论中所述,使用以下参数:
def identify_unique_msgid(self, smsreport_list):
msgid_i_to_be_crosschecked = smsreport_list.get('msgid_i')
msgid_ii_to_be_crosschecked = smsreport_list.get('msgid_ii')
find_command = 'SELECT * FROM myTable WHERE msgid_i = :msgid'
return find_command, dict(msgid = msgid_i_to_be_crosschecked)
cursor = connection.cursor()
smsreport_text_new = tuple(smsreport_text)
find_command, args = self.identify_unique_msgid(smsreport_list)
cursor.execute(find_command, args)
内容总结
以上是互联网集市为您收集整理的python – cx_Oracle:错误933. ORA-00933:“SQL命令未正确结束”:SQL命令错误?全部内容,希望文章能够帮你解决python – cx_Oracle:错误933. ORA-00933:“SQL命令未正确结束”:SQL命令错误?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。