Python cx_Oracle用qmark准备的语句 [英] Python cx_Oracle prepared statement with qmark
本文介绍了Python cx_Oracle用qmark准备的语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用cx_Oracle,但似乎不喜欢我对db-api的了解.
I am trying to work with cx_Oracle, but it seems to dislike what I know about db-api.
这些声明起作用:
cur.execute('INSERT INTO "testdboz" ("id", "sessionid") VALUES (2, 123)')
cur.execute('INSERT INTO "testdboz" ("id", "sessionid") VALUES (:id, :sid)',
{'id':1, 'sid':13})
cur.execute('INSERT INTO "testdboz" ("id", "sessionid") VALUES (:1, :2)', [1123, 123])
但是,这失败了:
cur.execute('INSERT INTO "testdboz" ("id", "sessionid") VALUES (?, ?)', [1, 123])
以上操作失败,并显示:
The above fails with:
---------------------------------------------------------------------------
DatabaseError Traceback (most recent call last)
<ipython-input-17-4e9fe350f968> in <module>()
----> 1 cur.execute('INSERT INTO "testdboz" ("id", "sessionid") VALUES (?, ?)', [1, 123])
DatabaseError: ORA-01036: illegal variable name/number
有没有办法纠正这个说法? cx_Oracle
支持qmark
吗?
Is there a way to correct this statement? Does cx_Oracle
suppprt qmark
?
推荐答案
Sadly, I found an answer here...
您无法真正选择想要使用的参数样式.甲骨文 仅本地支持命名和数字paramstyles和cx_Oracle 支持这两个.
You can't truly choose what paramstyle you would like to use. Oracle only natively supports named and numeric paramstyles and cx_Oracle supports both of those.
这篇关于Python cx_Oracle用qmark准备的语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文