问题
I am trying to work with cx_Oracle, but it seems to dislike what I know about db-api.
These statement work:
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])
However, this fails:
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
Is there a way to correct this statement? Does cx_Oracle
suppprt qmark
?
回答1:
Sadly, I found an answer here...
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.
来源:https://stackoverflow.com/questions/23829828/python-cx-oracle-prepared-statement-with-qmark