oracle报错 933,cx_Oracle:错误933. ORA-00933:“SQL命令未正确结束”:SQL命令错误?...

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。

2017-05-09

pymat

+1

使用的参数,而不是直接把字符串值。实际上,你需要围绕字符串常量使用单引号。 –

+0

@GordonLinoff你的意思是find_command应该类似于上面的插入命令? –

+0

你可以使用这个我猜''如果你不太在意SELECT * FROM myTable WHERE msgid_i = \'{0} \'“',但是你应该使用参数化查询。 –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值