Python Cx_oracle Sql With Bind String Variable
I have a problem with creating SQL query for Oracle database using Python. I want to bind string variable and it does not work, could you tell me what am I doing wrong? This is my
Solution 1:
You're using a dictionary ({'doknr' : doknumber}
) for your parameter, so it's a named parameter - the :param
needs to match the key name. Try this:
query = "SELECT * FROM DOCUMENT WHERE DOC = :doknr"for doknumber in dokList:
cursor.execute(query, {'doknr':doknumber})
print(cursor.rowcount)
For future troubleshooting, to check whether your parameter is getting passed properly, you can also try changing your query to "select :param from dual"
.
Post a Comment for "Python Cx_oracle Sql With Bind String Variable"